设置工作路径,加载包

library(rgdal)
## Warning: package 'rgdal' was built under R version 3.5.3
## Loading required package: sp
## Warning: package 'sp' was built under R version 3.5.3
## rgdal: version: 1.4-3, (SVN revision 828)
##  Geospatial Data Abstraction Library extensions to R successfully loaded
##  Loaded GDAL runtime: GDAL 2.2.3, released 2017/11/20
##  Path to GDAL shared files: C:/Program Files/R/R-3.5.2/library/rgdal/gdal
##  GDAL binary built with GEOS: TRUE 
##  Loaded PROJ.4 runtime: Rel. 4.9.3, 15 August 2016, [PJ_VERSION: 493]
##  Path to PROJ.4 shared files: C:/Program Files/R/R-3.5.2/library/rgdal/proj
##  Linking to sp version: 1.3-1
library(raster)
## Warning: package 'raster' was built under R version 3.5.3
library(randomForest)
## Warning: package 'randomForest' was built under R version 3.5.3
## randomForest 4.6-14
## Type rfNews() to see new features/changes/bug fixes.

构建环境因子图层

setwd("E:/soilPaper/modling/EnFactor")

files<-c("DEM.tif","Slope.tif","PlanC.tif","ProfileC.tif","TWI.tif","Bedrock.tif","LSF.tif","VD.tif","RSP.tif")

covStack <- raster(files[1])
for (i in 2:length(files)) {
  covStack <- stack(covStack, files[i])
}

#设置读取样点数据路径
point_shp_folder="E:/soilPaper/modling/allTrainingSamples_shp/"

#设置最终结果tif的保存路径
result_tif_folder="E:/soilPaper/modling/result_mapTif/"

##设置随机数种子
set.seed(2019)

soil_type<-c(1,3,7,20,21,23,30,31,501,502,503)  # 41样本数量太少,删掉。
sampleNum_dict<-list()

单因子分析

DEM -ok

ns3

SNA DEM ns3 15

mn="All_pSNA_DEM_NS3_pen15" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pSNA_DEM_NS3_pen15.shp", layer: "All_pSNA_DEM_NS3_pen15"
## with 1045 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 1040   10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 16.73%
## Confusion matrix:
##     1  20 21 23  3 30 31 501 502 503   7 class.error
## 1   3   0  0  0  1  0  0   0   0   0   0  0.25000000
## 20  0 124 10  0  0  0  0   0   0  17   9  0.22500000
## 21  0  21 36  0  0  0  0   0   0   3   0  0.40000000
## 23  0   0  0 80  0  6  1   0   0  12   3  0.21568627
## 3   0   0  0  0 50  0  0   5   0   0   0  0.09090909
## 30  0   0  0 16  0 15  2   0   0   0   0  0.54545455
## 31  0   0  0  2  0  1 37   0   0   0   0  0.07500000
## 501 0   0  0  0  7  0  0 165   0   0   0  0.04069767
## 502 0   2  2  0  0  0  0   7  10   0   1  0.54545455
## 503 0  12  0  4  0  0  0   0   0 223   7  0.09349593
## 7   0  10  0  0  0  0  0   0   2  11 123  0.15753425
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

SNA DEM ns3 30

mn="All_pSNA_DEM_NS3_pen30" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pSNA_DEM_NS3_pen30.shp", layer: "All_pSNA_DEM_NS3_pen30"
## with 2045 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 2040   10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 15.59%
## Confusion matrix:
##     1  20 21  23  3 30 31 501 502 503   7 class.error
## 1   8   0  0   0  2  0  0   0   0   0   0  0.20000000
## 20  0 239 19   0  0  0  0   1   1  31  22  0.23642173
## 21  0  35 73   0  0  0  0   0   1   4   0  0.35398230
## 23  0   0  0 155  0 17  2   0   0  16   4  0.20103093
## 3   1   0  0   0 98  0  0  11   0   0   0  0.10909091
## 30  0   0  0  19  0 42  2   0   0   0   0  0.33333333
## 31  0   0  0   5  0  1 73   0   0   0   0  0.07594937
## 501 0   0  0   0 13  0  0 328   0   0   1  0.04093567
## 502 0   4  3   0  0  0  0   7  23   1   3  0.43902439
## 503 0  25  0  12  0  0  0   0   0 434  17  0.11065574
## 7   0  13  0   2  0  1  0   1   2  19 249  0.13240418
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

SNA DEM ns3 45

mn="All_pSNA_DEM_NS3_pen45" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pSNA_DEM_NS3_pen45.shp", layer: "All_pSNA_DEM_NS3_pen45"
## with 3041 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 3036   10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 14.49%
## Confusion matrix:
##      1  20  21  23   3 30  31 501 502 503   7 class.error
## 1   15   0   0   0   1  0   0   0   0   0   0  0.06250000
## 20   0 368  27   0   0  0   0   0   2  32  35  0.20689655
## 21   0  54 106   0   0  0   0   0   1   6   0  0.36526946
## 23   0   0   0 241   0 19   6   0   0  17   4  0.16027875
## 3    2   0   0   0 139  0   0  23   0   0   0  0.15243902
## 30   0   0   0  16   0 71   4   0   0   0   1  0.22826087
## 31   0   0   0   7   0  5 106   0   0   0   0  0.10169492
## 501  0   0   0   0  20  0   0 490   1   0   2  0.04483431
## 502  0   0   2   0   0  0   0   7  45   2   5  0.26229508
## 503  0  40   1  15   0  0   0   0   0 649  22  0.10729023
## 7    0  25   0   4   0  1   0   3   3  25 366  0.14285714
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

RAN DEM ns3 15

mn="All_pRAN_DEM_NS3_pen15" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pRAN_DEM_NS3_pen15.shp", layer: "All_pRAN_DEM_NS3_pen15"
## with 1045 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 1042   10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 24.66%
## Confusion matrix:
##     1 20 21 23  3 30 31 501 502 503   7 class.error
## 1   4  0  0  0  2  0  0   0   0   0   0  0.33333333
## 20  0 97 16  0  0  0  0   2   0  28  17  0.39375000
## 21  0 21 35  0  0  0  0   0   1   2   1  0.41666667
## 23  0  0  0 72  0  5  4   0   0  20   1  0.29411765
## 3   0  0  0  0 48  0  0   7   0   0   0  0.12727273
## 30  0  0  0  4  0 21  5   0   0   0   3  0.36363636
## 31  0  0  0  7  0  3 28   0   0   2   0  0.30000000
## 501 0  1  0  0  8  0  0 158   0   0   5  0.08139535
## 502 0  9  0  0  0  0  0   3  10   0   0  0.54545455
## 503 0 24  1 14  0  0  0   1   0 200   6  0.18699187
## 7   0 14  0  4  0  2  0   6   1   7 112  0.23287671
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

RAN DEM ns3 30

mn="All_pRAN_DEM_NS3_pen30" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pRAN_DEM_NS3_pen30.shp", layer: "All_pRAN_DEM_NS3_pen30"
## with 2045 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 2042   10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 21.55%
## Confusion matrix:
##      1  20 21  23  3 30 31 501 502 503   7 class.error
## 1   12   0  0   0  0  0  0   0   0   0   0   0.0000000
## 20   0 211 22   0  0  0  0   4   1  48  27   0.3258786
## 21   0  34 69   0  0  0  0   1   1   8   0   0.3893805
## 23   0   0  0 139  0  7 10   0   0  32   6   0.2835052
## 3    1   0  0   0 86  0  0  23   0   0   0   0.2181818
## 30   0   0  0  15  0 39  5   0   0   0   4   0.3809524
## 31   0   0  0  12  0  2 65   0   0   0   0   0.1772152
## 501  0   2  0   0 23  0  0 305   1   0  11   0.1081871
## 502  0   2  2   0  0  0  0   1  29   0   7   0.2926829
## 503  0  31  7  22  0  0  0   0   2 414  12   0.1516393
## 7    0  20  0   3  0  2  0  12   2  15 233   0.1881533
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

RAN DEM ns3 45

mn="All_pRAN_DEM_NS3_pen45" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pRAN_DEM_NS3_pen45.shp", layer: "All_pRAN_DEM_NS3_pen45"
## with 3041 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 3038   10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 18.24%
## Confusion matrix:
##      1  20 21  23   3 30 31 501 502 503   7 class.error
## 1   15   0  0   0   3  0  0   0   0   0   0  0.16666667
## 20   0 334 30   0   0  0  0   4   1  68  27  0.28017241
## 21   0  54 99   0   0  0  0   1   1  11   1  0.40718563
## 23   0   0  0 219   0 17  6   0   0  36   9  0.23693380
## 3    1   0  0   0 124  0  0  39   0   0   0  0.24390244
## 30   0   0  0  11   0 74  4   0   0   1   2  0.19565217
## 31   0   0  0  15   0  5 98   0   0   0   0  0.16949153
## 501  0   4  0   0  24  0  0 476   0   0   9  0.07212476
## 502  0   4  2   0   0  0  0   2  50   0   3  0.18032787
## 503  0  43  1  23   0  1  1   0   1 642  15  0.11691884
## 7    0  28  1   4   0  4  0  16   2  19 353  0.17330211
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

ns5

SNA DEM ns5 15

mn="All_pSNA_DEM_NS5_pen15" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pSNA_DEM_NS5_pen15.shp", layer: "All_pSNA_DEM_NS5_pen15"
## with 356 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 354  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 20.34%
## Confusion matrix:
##     20 21 23  3 30 31 501 502 503  7 class.error
## 20  30  5  0  0  0  0   0   0   7  6  0.37500000
## 21  10  9  0  0  0  0   0   1   2  0  0.59090909
## 23   0  0 26  0  1  1   0   0   0  2  0.13333333
## 3    0  0  0 19  0  0   1   0   0  0  0.05000000
## 30   0  0  5  0  2  0   0   0   0  1  0.75000000
## 31   0  0  1  0  0 12   0   0   0  0  0.07692308
## 501  0  0  0  1  0  0  65   0   0  0  0.01515152
## 502  2  2  0  0  0  0   3   1   0  0  0.87500000
## 503  1  1  1  0  0  0   0   0  77  6  0.10465116
## 7    3  0  0  0  0  0   0   0   9 41  0.22641509
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

SNA DEM ns5 30

mn="All_pSNA_DEM_NS5_pen30" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pSNA_DEM_NS5_pen30.shp", layer: "All_pSNA_DEM_NS5_pen30"
## with 679 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 677  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 16.69%
## Confusion matrix:
##     1 20 21 23  3 30 31 501 502 503  7 class.error
## 1   0  0  0  0  2  0  0   0   0   0  0  1.00000000
## 20  0 64  4  0  0  0  0   0   0  10 12  0.28888889
## 21  0 12 18  0  0  0  0   0   1   2  0  0.45454545
## 23  0  0  0 48  0  2  1   0   0   1  3  0.12727273
## 3   0  0  0  0 38  0  0   2   0   0  0  0.05000000
## 30  0  0  0 13  0  2  0   0   0   0  0  0.86666667
## 31  0  0  0  1  0  0 25   0   0   0  0  0.03846154
## 501 0  0  0  0  3  0  0 128   0   0  0  0.02290076
## 502 0  3  2  0  0  0  0   5   4   0  1  0.73333333
## 503 0  5  0  2  0  0  0   0   0 154  5  0.07228916
## 7   0  6  0  1  0  0  0   2   0  12 83  0.20192308
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

SNA DEM ns5 45

mn="All_pSNA_DEM_NS5_pen45" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pSNA_DEM_NS5_pen45.shp", layer: "All_pSNA_DEM_NS5_pen45"
## with 995 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 993  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 16.21%
## Confusion matrix:
##     1 20 21 23  3 30 31 501 502 503   7 class.error
## 1   3  0  0  0  1  0  0   0   0   0   0  0.25000000
## 20  0 94  8  0  0  0  0   0   1  12  13  0.26562500
## 21  0 15 29  0  0  0  0   0   0   1   0  0.35555556
## 23  0  0  0 71  0  7  1   0   0   2   2  0.14457831
## 3   0  0  0  0 54  0  0   5   0   0   0  0.08474576
## 30  0  0  0 13  0  6  0   0   0   0   0  0.68421053
## 31  0  0  0  1  0  0 38   0   0   0   0  0.02564103
## 501 0  0  0  0  7  0  0 190   0   0   0  0.03553299
## 502 0  5  2  0  0  0  0   8   6   0   1  0.72727273
## 503 0 11  0  3  0  0  0   0   0 223  11  0.10080645
## 7   0 11  0  1  0  0  0   2   0  17 118  0.20805369
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

RAN DEM ns5 15

mn="All_pRAN_DEM_NS5_pen15" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pRAN_DEM_NS5_pen15.shp", layer: "All_pRAN_DEM_NS5_pen15"
## with 356 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 356  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 25%
## Confusion matrix:
##     1 20 21 23  3 30 31 501 502 503  7 class.error
## 1   0  0  0  0  2  0  0   0   0   0  0   1.0000000
## 20  0 29  3  0  0  0  0   1   1   9  5   0.3958333
## 21  0 10 10  0  0  0  0   0   0   2  0   0.5454545
## 23  0  0  0 22  0  3  1   0   0   3  1   0.2666667
## 3   0  0  0  0 15  0  0   5   0   0  0   0.2500000
## 30  0  0  0  3  0  4  0   0   0   0  1   0.5000000
## 31  0  0  0  2  0  0 11   0   0   0  0   0.1538462
## 501 0  0  0  0  5  0  0  59   1   0  1   0.1060606
## 502 0  4  0  0  0  0  0   3   1   0  0   0.8750000
## 503 0  4  0  4  0  0  0   0   0  77  1   0.1046512
## 7   0  6  0  0  0  1  0   3   0   4 39   0.2641509
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

RAN DEM ns5 30

mn="All_pRAN_DEM_NS5_pen30" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pRAN_DEM_NS5_pen30.shp", layer: "All_pRAN_DEM_NS5_pen30"
## with 679 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 679  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 19.73%
## Confusion matrix:
##     1 20 21 23  3 30 31 501 502 503  7 class.error
## 1   2  0  0  0  2  0  0   0   0   0  0  0.50000000
## 20  0 57 10  0  0  0  0   1   2  10 10  0.36666667
## 21  0 13 19  0  0  0  0   0   0   1  0  0.42424242
## 23  0  0  0 40  0  4  2   0   0   6  3  0.27272727
## 3   1  0  0  0 34  0  0   5   0   0  0  0.15000000
## 30  0  0  0  8  0  4  3   0   0   0  0  0.73333333
## 31  0  0  0  6  0  1 19   0   0   0  0  0.26923077
## 501 0  1  0  0  5  0  0 124   0   0  1  0.05343511
## 502 0  3  0  0  0  0  0   1   9   1  1  0.40000000
## 503 0  6  0  3  0  0  0   0   0 153  4  0.07831325
## 7   0  8  0  2  0  0  0   4   0   6 84  0.19230769
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

RAN DEM ns5 45

mn="All_pRAN_DEM_NS5_pen45" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pRAN_DEM_NS5_pen45.shp", layer: "All_pRAN_DEM_NS5_pen45"
## with 995 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 995  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 18.09%
## Confusion matrix:
##     1 20 21 23  3 30 31 501 502 503   7 class.error
## 1   4  0  0  0  2  0  0   0   0   0   0  0.33333333
## 20  0 87  9  0  0  0  0   1   2  17  12  0.32031250
## 21  0 14 27  0  0  0  0   0   2   2   0  0.40000000
## 23  0  0  0 59  0  7  1   0   0  12   4  0.28915663
## 3   0  0  0  0 46  0  0  13   0   0   0  0.22033898
## 30  0  0  0  7  0  8  2   0   0   0   2  0.57894737
## 31  0  0  0  2  0  0 37   0   0   0   0  0.05128205
## 501 0  2  0  0  7  0  0 187   1   0   0  0.05076142
## 502 0  6  0  0  0  0  0   1  14   0   1  0.36363636
## 503 0 13  1  8  0  0  0   0   0 220   6  0.11290323
## 7   0  9  0  2  0  3  0   3   1   5 126  0.15436242
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

ns7

SNA DEM ns7 15

mn="All_pSNA_DEM_NS7_pen15" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pSNA_DEM_NS7_pen15.shp", layer: "All_pSNA_DEM_NS7_pen15"
## with 131 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 130  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 26.15%
## Confusion matrix:
##     20 21 23 3 30 31 501 502 503  7 class.error
## 20  12  1  0 0  0  0   0   0   3  2   0.3333333
## 21   2  1  0 0  0  0   0   1   0  0   0.7500000
## 23   0  0 10 0  1  0   0   0   0  1   0.1666667
## 3    0  0  0 6  0  0   1   0   0  0   0.1428571
## 30   0  0  2 0  0  0   0   0   1  0   1.0000000
## 31   0  0  1 0  0  3   0   0   0  0   0.2500000
## 501  1  0  0 0  0  0  24   0   0  0   0.0400000
## 502  2  0  0 0  0  0   2   0   0  0   1.0000000
## 503  4  0  0 0  0  0   0   0  24  3   0.2258065
## 7    1  0  0 0  0  0   0   0   5 16   0.2727273
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

SNA DEM ns7 30

mn="All_pSNA_DEM_NS7_pen30" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pSNA_DEM_NS7_pen30.shp", layer: "All_pSNA_DEM_NS7_pen30"
## with 227 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 226  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 18.14%
## Confusion matrix:
##     20 21 23  3 30 31 501 502 503  7 class.error
## 20  16  1  0  0  0  0   0   0   7  3   0.4074074
## 21   3  3  0  0  0  0   0   0   0  0   0.5000000
## 23   0  0 18  0  2  0   0   0   0  0   0.1000000
## 3    0  0  0 13  0  0   0   0   0  0   0.0000000
## 30   0  0  3  0  0  0   0   0   0  1   1.0000000
## 31   0  0  0  0  0  7   0   0   0  0   0.0000000
## 501  0  0  0  0  0  0  49   0   0  0   0.0000000
## 502  1  1  0  0  0  0   3   0   0  1   1.0000000
## 503  3  0  0  0  0  0   0   0  49  4   0.1250000
## 7    1  0  0  0  0  0   0   0   7 30   0.2105263
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

SNA DEM ns7 45

mn="All_pSNA_DEM_NS7_pen45" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pSNA_DEM_NS7_pen45.shp", layer: "All_pSNA_DEM_NS7_pen45"
## with 327 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 326  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 15.64%
## Confusion matrix:
##     1 20 21 23  3 30 31 501 502 503  7 class.error
## 1   0  0  0  0  1  0  0   0   0   0  0  1.00000000
## 20  0 26  2  0  0  0  0   0   0   5  3  0.27777778
## 21  0  3  4  0  0  0  0   0   1   0  0  0.50000000
## 23  0  0  0 24  0  2  1   0   0   1  1  0.17241379
## 3   0  0  0  0 19  0  0   1   0   0  0  0.05000000
## 30  0  0  0  4  0  0  0   0   0   0  1  1.00000000
## 31  0  0  0  0  0  0 10   0   0   0  0  0.00000000
## 501 0  0  0  0  1  0  0  73   0   0  0  0.01351351
## 502 0  2  1  0  0  0  0   4   1   0  0  0.87500000
## 503 0  3  0  2  0  0  0   0   0  74  4  0.10843373
## 7   0  1  0  1  0  0  0   0   0   6 44  0.15384615
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

RAN DEM ns7 15

mn="All_pRAN_DEM_NS7_pen15" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pRAN_DEM_NS7_pen15.shp", layer: "All_pRAN_DEM_NS7_pen15"
## with 131 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 131  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 29.77%
## Confusion matrix:
##     1 20 21 23 3 30 31 501 502 503  7 class.error
## 1   0  0  0  0 1  0  0   0   0   0  0   1.0000000
## 20  0  9  1  0 0  0  0   0   0   2  6   0.5000000
## 21  0  2  2  0 0  0  0   0   0   0  0   0.5000000
## 23  0  0  0  7 0  1  0   0   0   4  0   0.4166667
## 3   1  0  0  0 5  0  0   1   0   0  0   0.2857143
## 30  0  0  0  3 0  0  0   0   0   0  0   1.0000000
## 31  0  0  0  0 0  0  4   0   0   0  0   0.0000000
## 501 0  1  0  0 1  0  0  22   0   0  1   0.1200000
## 502 0  1  0  0 0  0  0   1   1   0  1   0.7500000
## 503 0  3  0  3 0  0  0   0   0  24  1   0.2258065
## 7   0  2  0  0 0  0  0   0   0   2 18   0.1818182
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

RAN DEM ns7 30

mn="All_pRAN_DEM_NS7_pen30" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pRAN_DEM_NS7_pen30.shp", layer: "All_pRAN_DEM_NS7_pen30"
## with 227 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 227  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 19.82%
## Confusion matrix:
##     1 20 21 23  3 30 31 501 502 503  7 class.error
## 1   0  0  0  0  1  0  0   0   0   0  0  1.00000000
## 20  0 16  1  0  0  0  0   0   0   4  6  0.40740741
## 21  0  2  4  0  0  0  0   0   0   0  0  0.33333333
## 23  0  0  0 16  0  0  1   0   0   2  1  0.20000000
## 3   0  0  0  0 11  0  0   2   0   0  0  0.15384615
## 30  0  0  0  1  0  3  0   0   0   0  0  0.25000000
## 31  0  0  0  1  0  0  6   0   0   0  0  0.14285714
## 501 0  0  0  0  2  0  0  46   1   0  0  0.06122449
## 502 0  1  0  0  0  0  0   2   2   0  1  0.66666667
## 503 0  3  0  3  0  0  0   0   0  50  0  0.10714286
## 7   0  5  0  1  0  0  0   1   0   3 28  0.26315789
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

RAN DEM ns7 45

mn="All_pRAN_DEM_NS7_pen45" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pRAN_DEM_NS7_pen45.shp", layer: "All_pRAN_DEM_NS7_pen45"
## with 327 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 327  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 16.51%
## Confusion matrix:
##     1 20 21 23  3 30 31 501 502 503  7 class.error
## 1   1  0  0  0  1  0  0   0   0   0  0  0.50000000
## 20  0 25  1  0  0  0  0   0   0   5  5  0.30555556
## 21  0  3  4  0  0  0  0   0   1   0  0  0.50000000
## 23  0  0  0 22  0  2  1   0   0   4  0  0.24137931
## 3   0  0  0  0 18  0  0   2   0   0  0  0.10000000
## 30  0  0  0  2  0  3  0   0   0   0  0  0.40000000
## 31  0  0  0  1  0  0  9   0   0   0  0  0.10000000
## 501 0  0  0  0  2  0  0  71   0   0  1  0.04054054
## 502 0  2  0  0  0  0  0   2   3   0  1  0.62500000
## 503 0  2  0  4  0  0  0   0   0  75  2  0.09638554
## 7   0  4  0  0  0  0  0   1   0   5 42  0.19230769
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

Slope -ok

ns3

SNA Slope ns3 15

mn="All_pSNA_Slope_NS3_pen15" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pSNA_Slope_NS3_pen15.shp", layer: "All_pSNA_Slope_NS3_pen15"
## with 998 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 994  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 21.93%
## Confusion matrix:
##     1  20 21 23  3 30 31 501 502 503   7 class.error
## 1   1   0  0  0  3  0  0   0   0   0   0  0.75000000
## 20  0 104 12  0  0  0  0   2   1  17  19  0.32903226
## 21  0  23 33  0  0  0  0   0   1   2   0  0.44067797
## 23  0   0  0 80  0  4  5   0   0  11   0  0.20000000
## 3   1   0  0  0 40  0  0  11   0   0   0  0.23076923
## 30  0   1  0  8  0 22  1   0   0   0   1  0.33333333
## 31  0   0  0  4  0  0 37   0   0   0   0  0.09756098
## 501 0   2  0  0  9  0  0 145   1   0   2  0.08805031
## 502 0   5  0  0  0  0  0   0  15   0   2  0.31818182
## 503 0  16  0 13  0  0  0   0   0 192   7  0.15789474
## 7   0  17  0  0  0  3  0   6   1   7 107  0.24113475
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

SNA Slope ns3 30

mn="All_pSNA_Slope_NS3_pen30" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pSNA_Slope_NS3_pen30.shp", layer: "All_pSNA_Slope_NS3_pen30"
## with 1951 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 1947   10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 19.26%
## Confusion matrix:
##     1  20 21  23  3 30 31 501 502 503   7 class.error
## 1   7   0  0   0  3  0  0   0   0   0   0  0.30000000
## 20  0 213 13   0  0  0  0   4   2  42  29  0.29702970
## 21  0  41 63   0  0  0  0   0   2   5   0  0.43243243
## 23  0   0  0 154  0  8  5   0   0  21   3  0.19371728
## 3   2   0  0   0 84  0  0  18   0   0   0  0.19230769
## 30  0   1  0   7  0 51  1   0   0   0   3  0.19047619
## 31  0   0  0   2  0  1 79   0   0   0   0  0.03658537
## 501 0   1  0   0 13  0  0 288   0   2  13  0.09148265
## 502 0   7  2   0  0  0  0   0  28   1   3  0.31707317
## 503 0  29  2  17  0  1  0   0   2 388  10  0.13585746
## 7   0  24  1   0  0  1  0  14   1  18 217  0.21376812
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

SNA Slope ns3 45

mn="All_pSNA_Slope_NS3_pen45" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pSNA_Slope_NS3_pen45.shp", layer: "All_pSNA_Slope_NS3_pen45"
## with 2889 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 2885   10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 18.72%
## Confusion matrix:
##      1  20 21  23   3 30  31 501 502 503   7 class.error
## 1   12   0  0   0   4  0   0   0   0   0   0  0.25000000
## 20   0 305 25   0   0  0   0   5   3  63  46  0.31767338
## 21   0  60 91   0   0  0   0   1   4   5   0  0.43478261
## 23   0   0  0 228   0 12   4   0   0  32   6  0.19148936
## 3    3   0  0   0 128  0   0  24   0   0   0  0.17419355
## 30   0   1  0  11   0 72   4   0   0   0   3  0.20879121
## 31   0   0  0   8   0  2 113   0   0   0   0  0.08130081
## 501  0   0  0   0  14  0   0 446   0   0  14  0.05907173
## 502  0   4  2   0   0  0   0   1  47   2   4  0.21666667
## 503  0  55  4  24   0  1   0   0   2 571  11  0.14520958
## 7    0  32  0   0   0  4   0  18   1  21 332  0.18627451
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

RAN Slope ns3 15

mn="All_pRAN_Slope_NS3_pen15" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pRAN_Slope_NS3_pen15.shp", layer: "All_pRAN_Slope_NS3_pen15"
## with 998 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 996  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 27.41%
## Confusion matrix:
##     1  20 21 23  3 30 31 501 502 503   7 class.error
## 1   6   0  0  0  0  0  0   0   0   0   0  0.00000000
## 20  0 104 14  0  0  0  0   3   0  22  12  0.32903226
## 21  0  33 20  0  0  0  0   0   0   5   1  0.66101695
## 23  0   0  0 69  0  9  3   0   0  16   3  0.31000000
## 3   0   0  0  0 41  0  0  11   0   0   0  0.21153846
## 30  0   0  0  8  0 17  4   0   0   2   2  0.48484848
## 31  0   0  0  9  0  4 28   0   0   0   0  0.31707317
## 501 0   2  0  0  8  0  0 144   0   0   5  0.09433962
## 502 0   6  0  0  0  0  0   3  12   0   1  0.45454545
## 503 0  19  4 15  0  1  0   0   0 177  12  0.22368421
## 7   0  15  0  1  0  4  0   7   1   8 105  0.25531915
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

RAN Slope ns3 30

mn="All_pRAN_Slope_NS3_pen30" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pRAN_Slope_NS3_pen30.shp", layer: "All_pRAN_Slope_NS3_pen30"
## with 1951 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 1948   10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 22.07%
## Confusion matrix:
##      1  20 21  23  3 30 31 501 502 503   7 class.error
## 1   11   0  0   0  0  0  0   0   0   0   0  0.00000000
## 20   0 199 24   0  0  0  0   4   1  44  31  0.34323432
## 21   0  39 58   0  0  0  0   0   2  12   0  0.47747748
## 23   0   0  0 150  0  5  8   0   0  21   7  0.21465969
## 3    1   0  0   0 78  0  0  25   0   0   0  0.25000000
## 30   0   0  0  20  0 39  2   0   0   0   2  0.38095238
## 31   0   0  0  11  0  4 67   0   0   0   0  0.18292683
## 501  0   4  0   0 14  0  0 288   1   0  10  0.09148265
## 502  0   3  1   0  0  0  0   2  30   0   5  0.26829268
## 503  0  34  4  19  0  2  0   0   0 375  15  0.16481069
## 7    0  27  0   1  0  1  0  11   3  10 223  0.19202899
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

RAN Slope ns3 45

mn="All_pRAN_Slope_NS3_pen45" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pRAN_Slope_NS3_pen45.shp", layer: "All_pRAN_Slope_NS3_pen45"
## with 2889 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 2886   10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 19.4%
## Confusion matrix:
##      1  20 21  23   3 30  31 501 502 503   7 class.error
## 1   15   0  0   0   2  0   0   0   0   0   0   0.1176471
## 20   0 334 21   1   0  1   0   5   2  60  23   0.2527964
## 21   0  52 91   0   0  0   0   0   2  14   2   0.4347826
## 23   0   0  0 220   0 16   7   0   0  31   8   0.2198582
## 3    2   0  0   0 121  0   0  32   0   0   0   0.2193548
## 30   0   0  0  19   0 63   6   0   0   0   3   0.3076923
## 31   0   0  0  13   0  6 104   0   0   0   0   0.1544715
## 501  0   5  0   0  28  0   0 430   2   0   9   0.0928270
## 502  0   5  2   0   0  0   0   3  44   0   6   0.2666667
## 503  0  44  4  27   0  1   1   0   1 573  17   0.1422156
## 7    0  31  0   2   0  3   0  18   6  17 331   0.1887255
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

ns5

SNA Slope ns5 15

mn="All_pSNA_Slope_NS5_pen15" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pSNA_Slope_NS5_pen15.shp", layer: "All_pSNA_Slope_NS5_pen15"
## with 336 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 336  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 24.4%
## Confusion matrix:
##     1 20 21 23  3 30 31 501 502 503  7 class.error
## 1   0  0  0  0  2  0  0   0   0   0  0  1.00000000
## 20  0 29  4  0  0  0  0   1   0   6  6  0.36956522
## 21  0  6 12  0  0  0  0   1   0   2  0  0.42857143
## 23  0  0  0 19  0  3  0   0   0   5  2  0.34482759
## 3   0  0  0  0 16  0  0   3   0   0  0  0.15789474
## 30  0  0  0  4  0  4  1   0   0   0  0  0.55555556
## 31  0  0  0  1  0  0 12   0   0   0  0  0.07692308
## 501 0  1  0  0  4  0  0  55   0   0  1  0.09836066
## 502 0  3  0  0  0  0  0   0   3   1  0  0.57142857
## 503 0  5  0  3  0  0  0   0   0  67  3  0.14102564
## 7   0  5  1  0  0  1  0   3   0   4 37  0.27450980
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

SNA Slope ns5 30

mn="All_pSNA_Slope_NS5_pen30" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pSNA_Slope_NS5_pen30.shp", layer: "All_pSNA_Slope_NS5_pen30"
## with 636 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 636  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 19.65%
## Confusion matrix:
##     1 20 21 23  3 30 31 501 502 503  7 class.error
## 1   3  0  0  0  1  0  0   0   0   0  0  0.25000000
## 20  0 55  6  0  0  0  0   2   0  12 11  0.36046512
## 21  0 10 21  0  0  0  0   1   0   1  0  0.36363636
## 23  0  0  0 41  0  4  1   0   0   7  1  0.24074074
## 3   1  0  0  0 29  0  0   7   0   0  0  0.21621622
## 30  0  0  0  4  0 11  1   0   0   0  0  0.31250000
## 31  0  0  0  1  0  0 24   0   0   0  0  0.04000000
## 501 0  1  0  0  7  0  0 110   0   0  3  0.09090909
## 502 0  2  1  0  0  0  0   0   9   0  2  0.35714286
## 503 0  9  0  4  0  0  0   0   0 135  3  0.10596026
## 7   0 11  0  0  0  1  0   4   0   6 73  0.23157895
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

SNA Slope ns5 45

mn="All_pSNA_Slope_NS5_pen45" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pSNA_Slope_NS5_pen45.shp", layer: "All_pSNA_Slope_NS5_pen45"
## with 931 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 929  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 18.3%
## Confusion matrix:
##     1 20 21 23  3 30 31 501 502 503   7 class.error
## 1   2  0  0  0  2  0  0   0   0   0   0  0.50000000
## 20  0 75  9  0  0  0  0   2   0  16  18  0.37500000
## 21  0 12 31  0  0  0  0   1   1   1   1  0.34042553
## 23  0  0  0 62  0  5  2   0   0   9   2  0.22500000
## 3   0  0  0  0 46  0  0   9   0   0   0  0.16363636
## 30  0  0  0  5  0 16  1   0   0   0   0  0.27272727
## 31  0  0  0  1  0  0 36   0   0   0   0  0.02702703
## 501 0  1  0  0  5  0  0 170   0   0   5  0.06077348
## 502 0  3  1  0  0  0  0   0  13   0   3  0.35000000
## 503 0 13  0  6  0  0  0   0   0 199   5  0.10762332
## 7   0 15  0  2  0  1  0   5   0   8 109  0.22142857
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

RAN Slope ns5 15

mn="All_pRAN_Slope_NS5_pen15" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pRAN_Slope_NS5_pen15.shp", layer: "All_pRAN_Slope_NS5_pen15"
## with 336 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 336  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 23.21%
## Confusion matrix:
##     1 20 21 23  3 30 31 501 502 503  7 class.error
## 1   1  0  0  0  1  0  0   0   0   0  0  0.50000000
## 20  0 27  5  0  0  0  0   1   0   7  6  0.41304348
## 21  0  7 12  0  0  0  0   0   0   2  0  0.42857143
## 23  0  0  0 22  0  3  0   0   0   3  1  0.24137931
## 3   0  0  0  0 16  0  0   3   0   0  0  0.15789474
## 30  0  0  0  2  0  1  2   0   0   0  4  0.88888889
## 31  0  0  0  1  0  0 12   0   0   0  0  0.07692308
## 501 0  0  0  0  2  0  0  59   0   0  0  0.03278689
## 502 0  3  0  0  0  0  0   3   0   0  1  1.00000000
## 503 0  3  0  2  0  0  0   0   0  70  3  0.10256410
## 7   0  5  0  0  0  3  0   2   0   3 38  0.25490196
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

RAN Slope ns5 30

mn="All_pRAN_Slope_NS5_pen30" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pRAN_Slope_NS5_pen30.shp", layer: "All_pRAN_Slope_NS5_pen30"
## with 636 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 636  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 21.07%
## Confusion matrix:
##     1 20 21 23  3 30 31 501 502 503  7 class.error
## 1   4  0  0  0  0  0  0   0   0   0  0  0.00000000
## 20  0 58 10  0  0  0  0   1   1   8  8  0.32558140
## 21  0 20 12  0  0  0  0   0   0   1  0  0.63636364
## 23  0  0  0 39  0  5  2   0   0   4  4  0.27777778
## 3   1  0  0  0 28  0  0   8   0   0  0  0.24324324
## 30  0  0  0  4  0 11  1   0   0   0  0  0.31250000
## 31  0  0  0  3  0  0 22   0   0   0  0  0.12000000
## 501 0  0  0  0  6  0  0 110   1   0  4  0.09090909
## 502 0  3  0  0  0  0  0   3   6   0  2  0.57142857
## 503 0  6  1  4  0  0  0   0   0 136  4  0.09933775
## 7   0  8  0  3  0  0  0   3   1   4 76  0.20000000
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

RAN Slope ns5 45

mn="All_pRAN_Slope_NS5_pen45" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pRAN_Slope_NS5_pen45.shp", layer: "All_pRAN_Slope_NS5_pen45"
## with 931 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 931  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 18.69%
## Confusion matrix:
##     1 20 21 23  3 30 31 501 502 503   7 class.error
## 1   3  0  0  0  3  0  0   0   0   0   0  0.50000000
## 20  0 83  6  0  0  0  0   0   3  16  12  0.30833333
## 21  0 17 27  0  0  0  0   0   1   2   0  0.42553191
## 23  0  0  0 53  0  8  3   0   0  14   2  0.33750000
## 3   1  0  0  0 48  0  0   6   0   0   0  0.12727273
## 30  0  0  0  6  0 13  0   0   0   0   3  0.40909091
## 31  0  0  0  5  0  1 31   0   0   0   0  0.16216216
## 501 0  0  0  0  8  0  0 171   0   0   2  0.05524862
## 502 0  4  0  0  0  0  0   4   9   0   3  0.55000000
## 503 0  6  1  9  0  0  0   0   0 201   6  0.09865471
## 7   0  6  0  1  0  1  0   3   1  10 118  0.15714286
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

ns7

SNA Slope ns7 15

mn="All_pSNA_Slope_NS7_pen15" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pSNA_Slope_NS7_pen15.shp", layer: "All_pSNA_Slope_NS7_pen15"
## with 121 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 121  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 28.93%
## Confusion matrix:
##     1 20 21 23 3 30 31 501 502 503  7 class.error
## 1   0  0  0  0 1  0  0   0   0   0  0  1.00000000
## 20  0 11  1  0 0  0  0   0   0   2  4  0.38888889
## 21  0  4  0  0 0  0  0   0   0   0  0  1.00000000
## 23  0  0  0  7 0  0  0   0   0   3  0  0.30000000
## 3   0  0  0  0 5  0  0   2   0   0  0  0.28571429
## 30  0  0  0  1 0  0  0   0   0   0  1  1.00000000
## 31  0  0  0  0 0  0  4   0   0   0  0  0.00000000
## 501 0  0  0  0 1  0  0  22   0   0  0  0.04347826
## 502 0  1  0  0 0  0  0   0   1   0  1  0.66666667
## 503 0  1  0  1 0  0  0   0   0  24  3  0.17241379
## 7   0  4  0  0 0  0  0   1   0   3 12  0.40000000
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

SNA Slope ns7 30

mn="All_pSNA_Slope_NS7_pen30" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pSNA_Slope_NS7_pen30.shp", layer: "All_pSNA_Slope_NS7_pen30"
## with 214 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 214  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 20.56%
## Confusion matrix:
##     1 20 21 23  3 30 31 501 502 503  7 class.error
## 1   0  0  0  0  1  0  0   0   0   0  0  1.00000000
## 20  0 16  1  0  0  0  0   0   1   4  5  0.40740741
## 21  0  2  3  0  0  0  0   0   0   0  0  0.40000000
## 23  0  0  0 13  0  0  0   0   0   4  0  0.23529412
## 3   0  0  0  0 12  0  0   2   0   0  0  0.14285714
## 30  0  0  0  0  0  3  0   0   0   0  0  0.00000000
## 31  0  0  0  0  0  0  7   0   0   0  0  0.00000000
## 501 0  0  0  0  1  0  0  43   0   0  2  0.06521739
## 502 0  1  0  0  2  0  0   1   0   0  1  1.00000000
## 503 0  1  0  3  0  0  0   0   0  45  4  0.15094340
## 7   0  2  0  0  0  0  0   1   0   5 28  0.22222222
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

SNA Slope ns7 45

mn="All_pSNA_Slope_NS7_pen45" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pSNA_Slope_NS7_pen45.shp", layer: "All_pSNA_Slope_NS7_pen45"
## with 307 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 307  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 15.64%
## Confusion matrix:
##     1 20 21 23  3 30 31 501 502 503  7 class.error
## 1   0  0  0  0  2  0  0   0   0   0  0  1.00000000
## 20  0 24  1  0  0  0  0   0   1   4  6  0.33333333
## 21  0  2  6  0  0  0  0   0   0   0  0  0.25000000
## 23  0  0  0 20  0  0  1   0   0   4  1  0.23076923
## 3   0  0  0  0 19  0  0   1   0   0  0  0.05000000
## 30  0  0  0  0  0  4  0   0   0   0  0  0.00000000
## 31  0  0  0  1  0  0  9   0   0   0  0  0.10000000
## 501 0  0  0  0  0  0  0  68   0   0  1  0.01449275
## 502 0  1  0  0  1  0  0   1   3   0  1  0.57142857
## 503 0  1  0  4  0  0  0   0   0  67  4  0.11842105
## 7   0  3  0  1  0  0  0   1   0   5 39  0.20408163
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

RAN Slope ns7 15

mn="All_pRAN_Slope_NS7_pen15" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pRAN_Slope_NS7_pen15.shp", layer: "All_pRAN_Slope_NS7_pen15"
## with 121 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 121  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 21.49%
## Confusion matrix:
##     1 20 21 23 3 30 31 501 502 503  7 class.error
## 1   0  0  0  0 1  0  0   0   0   0  0  1.00000000
## 20  0 13  0  0 0  0  0   0   0   2  3  0.27777778
## 21  0  2  2  0 0  0  0   0   0   0  0  0.50000000
## 23  0  0  0  7 0  0  1   0   0   2  0  0.30000000
## 3   1  0  0  0 5  0  0   1   0   0  0  0.28571429
## 30  0  0  0  2 0  0  0   0   0   0  0  1.00000000
## 31  0  0  0  2 0  0  2   0   0   0  0  0.50000000
## 501 0  0  0  0 0  0  0  23   0   0  0  0.00000000
## 502 0  1  1  0 0  0  0   1   0   0  0  1.00000000
## 503 0  2  0  0 0  0  0   0   0  27  0  0.06896552
## 7   0  1  0  1 0  0  0   0   0   2 16  0.20000000
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

RAN Slope ns7 30

mn="All_pRAN_Slope_NS7_pen30" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pRAN_Slope_NS7_pen30.shp", layer: "All_pRAN_Slope_NS7_pen30"
## with 214 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 214  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 17.76%
## Confusion matrix:
##     1 20 21 23  3 30 31 501 502 503  7 class.error
## 1   0  0  0  0  1  0  0   0   0   0  0  1.00000000
## 20  0 20  2  0  0  0  0   0   0   2  3  0.25925926
## 21  0  2  2  0  0  0  0   0   1   0  0  0.60000000
## 23  0  0  0 13  0  1  1   0   0   2  0  0.23529412
## 3   0  0  0  0 12  0  0   2   0   0  0  0.14285714
## 30  0  0  0  3  0  0  0   0   0   0  0  1.00000000
## 31  0  0  0  1  0  0  6   0   0   0  0  0.14285714
## 501 0  0  0  0  1  0  0  43   0   0  2  0.06521739
## 502 0  2  0  0  0  0  0   2   1   0  0  0.80000000
## 503 0  2  0  3  0  0  0   0   0  48  0  0.09433962
## 7   0  1  0  1  0  0  0   1   0   2 31  0.13888889
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

RAN Slope ns7 45

mn="All_pRAN_Slope_NS7_pen45" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pRAN_Slope_NS7_pen45.shp", layer: "All_pRAN_Slope_NS7_pen45"
## with 307 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 307  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 17.26%
## Confusion matrix:
##     1 20 21 23  3 30 31 501 502 503  7 class.error
## 1   1  0  0  0  1  0  0   0   0   0  0  0.50000000
## 20  0 25  2  0  0  0  0   0   0   3  6  0.30555556
## 21  0  4  4  0  0  0  0   0   0   0  0  0.50000000
## 23  0  0  0 19  0  1  2   0   0   4  0  0.26923077
## 3   2  0  0  0 16  0  0   2   0   0  0  0.20000000
## 30  0  0  0  4  0  0  0   0   0   0  0  1.00000000
## 31  0  0  0  1  0  0  9   0   0   0  0  0.10000000
## 501 0  0  0  0  2  0  0  66   0   0  1  0.04347826
## 502 0  2  0  0  0  0  0   2   3   0  0  0.57142857
## 503 0  3  0  3  0  0  0   0   0  68  2  0.10526316
## 7   0  3  0  0  0  0  0   1   0   2 43  0.12244898
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

PlanC -ok

ns3

SNA PlanC ns3 15

mn="All_pSNA_PlanC_NS3_pen15" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pSNA_PlanC_NS3_pen15.shp", layer: "All_pSNA_PlanC_NS3_pen15"
## with 1013 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 1011   10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 22.06%
## Confusion matrix:
##     1 20 21 23  3 30 31 501 502 503   7 class.error
## 1   4  0  0  0  2  0  0   0   0   0   0   0.3333333
## 20  0 98 15  0  0  0  0   1   0  25  17   0.3717949
## 21  0 25 32  0  0  0  0   0   0   2   0   0.4576271
## 23  0  0  0 88  0  3  1   0   0   8   0   0.1200000
## 3   1  0  0  0 41  0  0   9   0   0   0   0.1960784
## 30  0  0  0  6  0 23  0   0   0   2   2   0.3030303
## 31  0  0  0  7  0  1 34   0   0   0   0   0.1904762
## 501 0  2  0  0  8  0  0 149   0   0   6   0.0969697
## 502 0  2  0  0  0  0  0   2   9   0   8   0.5714286
## 503 0 24  2  6  0  2  0   0   0 193   6   0.1716738
## 7   0 10  0  0  0  2  0   7   3   6 117   0.1931034
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

SNA PlanC ns3 30

mn="All_pSNA_PlanC_NS3_pen30" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pSNA_PlanC_NS3_pen30.shp", layer: "All_pSNA_PlanC_NS3_pen30"
## with 1976 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 1973   10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 19.97%
## Confusion matrix:
##     1  20 21  23  3 30 31 501 502 503   7 class.error
## 1   8   0  0   0  2  0  0   0   0   0   0  0.20000000
## 20  0 196 28   0  0  0  0   3   1  46  29  0.35313531
## 21  0  41 57   0  0  0  0   2   0  11   1  0.49107143
## 23  0   0  0 156  0  5  3   0   0  24   1  0.17460317
## 3   2   0  0   0 80  0  0  19   0   0   0  0.20792079
## 30  0   0  0   9  0 49  1   0   0   1   3  0.22222222
## 31  0   0  0   5  0  1 78   0   0   0   0  0.07142857
## 501 0   1  1   0 12  0  0 306   1   0   9  0.07272727
## 502 0   5  1   0  0  0  0   2  24   1   7  0.40000000
## 503 0  43  1  14  0  3  0   0   0 390   9  0.15217391
## 7   0  17  0   0  0  1  0  13   2  13 235  0.16370107
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

SNA PlanC ns3 45

mn="All_pSNA_PlanC_NS3_pen45" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pSNA_PlanC_NS3_pen45.shp", layer: "All_pSNA_PlanC_NS3_pen45"
## with 2940 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 2937   10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 19.85%
## Confusion matrix:
##      1  20 21  23   3 30  31 501 502 503   7 class.error
## 1   13   0  0   0   2  0   0   0   0   0   0  0.13333333
## 20   0 295 29   0   0  0   0   5   3  72  46  0.34444444
## 21   0  59 89   0   0  0   0   2   1  13   1  0.46060606
## 23   0   0  0 224   0 11   6   0   0  36   4  0.20284698
## 3    2   0  0   0 113  0   0  37   0   0   0  0.25657895
## 30   0   0  0  10   0 72   2   0   0   1   6  0.20879121
## 31   0   0  0   5   0  1 119   0   0   0   0  0.04800000
## 501  0   1  1   0  28  0   0 447   1   0  15  0.09330629
## 502  0   2  1   0   0  0   0   2  47   1   5  0.18965517
## 503  0  58  1  20   0  2   0   0   1 591  15  0.14098837
## 7    0  33  0   0   0  3   0  20   1  18 344  0.17899761
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

RAN PlanC ns3 15

mn="All_pRAN_PlanC_NS3_pen15" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pRAN_PlanC_NS3_pen15.shp", layer: "All_pRAN_PlanC_NS3_pen15"
## with 1013 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 1011   10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 25.72%
## Confusion matrix:
##     1 20 21 23  3 30 31 501 502 503   7 class.error
## 1   5  0  0  0  1  0  0   0   0   0   0   0.1666667
## 20  0 92 19  0  0  0  0   1   0  28  16   0.4102564
## 21  0 19 36  0  0  0  0   0   0   4   0   0.3898305
## 23  0  0  0 73  0  7  3   0   0  14   3   0.2700000
## 3   1  0  0  0 37  0  0  13   0   0   0   0.2745098
## 30  0  0  0  9  0 17  4   0   0   1   2   0.4848485
## 31  0  0  0  6  0  3 33   0   0   0   0   0.2142857
## 501 0  2  0  0 12  0  0 145   0   0   6   0.1212121
## 502 0  5  2  0  0  0  0   3  10   1   0   0.5238095
## 503 0 18  2 10  0  1  0   0   2 192   8   0.1759657
## 7   0 13  0  1  0  0  0   9   1  10 111   0.2344828
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

RAN PlanC ns3 30

mn="All_pRAN_PlanC_NS3_pen30" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pRAN_PlanC_NS3_pen30.shp", layer: "All_pRAN_PlanC_NS3_pen30"
## with 1976 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 1973   10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 22.05%
## Confusion matrix:
##     1  20 21  23  3 30 31 501 502 503   7 class.error
## 1   9   0  0   0  1  0  0   0   0   0   0  0.10000000
## 20  0 191 33   0  0  0  0   5   0  48  26  0.36963696
## 21  0  43 60   0  0  0  0   0   0   9   0  0.46428571
## 23  0   0  0 134  0 13  3   0   0  32   7  0.29100529
## 3   0   0  0   0 78  0  0  23   0   0   0  0.22772277
## 30  0   0  0  12  0 44  4   0   0   1   2  0.30158730
## 31  0   0  0   9  0  4 70   0   0   1   0  0.16666667
## 501 0   1  0   0 16  0  0 304   1   0   8  0.07878788
## 502 0   7  0   0  0  0  0   5  26   1   1  0.35000000
## 503 0  26  3  19  0  1  1   0   1 399  10  0.13260870
## 7   0  22  0   3  0  0  0  17   1  15 223  0.20640569
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

RAN PlanC ns3 45

mn="All_pRAN_PlanC_NS3_pen45" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pRAN_PlanC_NS3_pen45.shp", layer: "All_pRAN_PlanC_NS3_pen45"
## with 2940 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 2937   10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 18.05%
## Confusion matrix:
##      1  20  21  23   3 30  31 501 502 503   7 class.error
## 1   14   0   0   0   1  0   0   0   0   0   0  0.06666667
## 20   0 320  32   1   0  0   0   2   3  63  29  0.28888889
## 21   0  46 106   0   0  0   0   0   2  11   0  0.35757576
## 23   0   0   0 225   0 14   4   0   0  29   9  0.19928826
## 3    2   0   0   0 113  0   0  37   0   0   0  0.25657895
## 30   0   0   0  13   0 70   4   0   0   2   2  0.23076923
## 31   0   0   0  12   0  4 108   0   0   1   0  0.13600000
## 501  0   4   0   0  25  0   0 455   1   0   8  0.07707911
## 502  0   2   2   0   0  0   0   2  50   1   1  0.13793103
## 503  0  45   4  27   0  1   1   0   2 592  16  0.13953488
## 7    0  20   0   4   0  3   0  16   2  20 354  0.15513126
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

ns5

SNA PlanC ns5 15

mn="All_pSNA_PlanC_NS5_pen15" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pSNA_PlanC_NS5_pen15.shp", layer: "All_pSNA_PlanC_NS5_pen15"
## with 345 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 345  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 26.96%
## Confusion matrix:
##     1 20 21 23  3 30 31 501 502 503  7 class.error
## 1   0  0  0  0  2  0  0   0   0   0  0   1.0000000
## 20  0 22  6  0  0  0  0   0   0   9  8   0.5111111
## 21  0  8 12  0  0  0  0   0   0   2  0   0.4545455
## 23  0  0  0 21  0  2  1   0   0   5  0   0.2758621
## 3   1  0  0  0 13  0  0   4   0   0  0   0.2777778
## 30  0  0  0  2  0  7  0   0   0   0  0   0.2222222
## 31  0  0  0  2  0  0 12   0   0   0  0   0.1428571
## 501 0  0  0  0  7  0  0  56   0   0  1   0.1250000
## 502 0  2  0  0  0  0  0   2   1   1  1   0.8571429
## 503 0  7  1  3  0  0  0   0   0  68  3   0.1707317
## 7   0  6  0  0  0  1  0   1   0   5 40   0.2452830
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

SNA PlanC ns5 30

mn="All_pSNA_PlanC_NS5_pen30" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pSNA_PlanC_NS5_pen30.shp", layer: "All_pSNA_PlanC_NS5_pen30"
## with 650 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 649  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 21.26%
## Confusion matrix:
##     1 20 21 23  3 30 31 501 502 503  7 class.error
## 1   1  0  0  0  2  0  0   0   0   0  0  0.66666667
## 20  0 46 11  0  0  0  0   0   0  14 13  0.45238095
## 21  0 15 15  0  0  0  0   0   1   3  0  0.55882353
## 23  0  0  0 44  0  2  3   0   0   6  0  0.20000000
## 3   1  0  0  0 26  0  0   9   0   0  0  0.27777778
## 30  0  0  0  3  0  9  2   0   0   0  0  0.35714286
## 31  0  0  0  3  0  0 24   0   0   0  0  0.11111111
## 501 0  0  0  0  9  0  0 116   0   0  2  0.08661417
## 502 0  5  0  0  0  0  0   1   6   1  1  0.57142857
## 503 0  7  3  5  0  0  0   0   0 135  5  0.12903226
## 7   0  5  0  0  0  1  0   1   1   3 89  0.11000000
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

SNA PlanC ns5 45

mn="All_pSNA_PlanC_NS5_pen45" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pSNA_PlanC_NS5_pen45.shp", layer: "All_pSNA_PlanC_NS5_pen45"
## with 954 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 953  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 19.52%
## Confusion matrix:
##     1 20 21 23  3 30 31 501 502 503   7 class.error
## 1   2  0  0  0  2  0  0   0   0   0   0  0.50000000
## 20  0 71 11  0  0  0  0   0   0  22  16  0.40833333
## 21  0 17 23  0  0  0  0   0   1   4   0  0.48888889
## 23  0  0  0 63  0  3  5   0   0   9   0  0.21250000
## 3   2  0  0  0 35  0  0  17   0   0   0  0.35185185
## 30  0  0  0  2  0 17  2   0   0   0   0  0.19047619
## 31  0  0  0  4  0  0 36   0   0   0   0  0.10000000
## 501 0  0  0  0 14  0  0 173   0   0   3  0.08947368
## 502 0  2  0  0  0  0  0   2  12   1   3  0.40000000
## 503 0  9  1  7  0  1  0   0   0 207   7  0.10775862
## 7   0  7  0  0  0  1  0   5   0   6 128  0.12925170
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

RAN PlanC ns5 15

mn="All_pRAN_PlanC_NS5_pen15" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pRAN_PlanC_NS5_pen15.shp", layer: "All_pRAN_PlanC_NS5_pen15"
## with 345 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 345  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 28.41%
## Confusion matrix:
##     1 20 21 23  3 30 31 501 502 503  7 class.error
## 1   0  0  0  0  2  0  0   0   0   0  0   1.0000000
## 20  0 25  5  0  0  0  0   0   1   7  7   0.4444444
## 21  0 11  8  0  0  0  0   0   1   2  0   0.6363636
## 23  0  0  0 18  0  3  0   0   0   4  4   0.3793103
## 3   0  0  0  0 14  0  0   4   0   0  0   0.2222222
## 30  0  0  0  6  0  1  2   0   0   0  0   0.8888889
## 31  0  0  0  1  0  2 10   0   0   0  1   0.2857143
## 501 0  2  0  0  1  0  0  59   0   0  2   0.0781250
## 502 0  3  0  0  0  0  0   1   2   1  0   0.7142857
## 503 0  2  2  2  0  0  0   0   0  73  3   0.1097561
## 7   0  5  0  1  0  1  0   5   0   4 37   0.3018868
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

RAN PlanC ns5 30

mn="All_pRAN_PlanC_NS5_pen30" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pRAN_PlanC_NS5_pen30.shp", layer: "All_pRAN_PlanC_NS5_pen30"
## with 650 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 650  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 19.38%
## Confusion matrix:
##     1 20 21 23  3 30 31 501 502 503  7 class.error
## 1   4  0  0  0  0  0  0   0   0   0  0  0.00000000
## 20  0 55 10  0  0  0  0   1   0  11  7  0.34523810
## 21  0 15 16  0  0  0  0   0   1   1  1  0.52941176
## 23  0  0  0 42  0  5  1   0   0   5  2  0.23636364
## 3   1  0  0  0 33  0  0   2   0   0  0  0.08333333
## 30  0  0  0  7  0  6  1   0   0   0  0  0.57142857
## 31  0  0  0  4  0  0 23   0   0   0  0  0.14814815
## 501 0  2  0  0  7  0  0 116   1   0  1  0.08661417
## 502 0  4  1  0  0  0  0   2   5   0  2  0.64285714
## 503 0  3  2  1  0  0  0   0   0 140  9  0.09677419
## 7   0  6  0  0  0  0  0   3   1   6 84  0.16000000
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

RAN PlanC ns5 45

mn="All_pRAN_PlanC_NS5_pen45" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pRAN_PlanC_NS5_pen45.shp", layer: "All_pRAN_PlanC_NS5_pen45"
## with 954 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 954  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 17.92%
## Confusion matrix:
##     1 20 21 23  3 30 31 501 502 503   7 class.error
## 1   4  0  0  0  1  0  0   0   0   0   0  0.20000000
## 20  0 80  7  0  0  0  0   1   0  16  16  0.33333333
## 21  0 20 20  0  0  0  0   0   0   4   1  0.55555556
## 23  0  0  0 55  0  7  4   0   0  11   3  0.31250000
## 3   0  0  0  0 45  0  0   9   0   0   0  0.16666667
## 30  0  0  0  6  0 13  0   0   0   0   2  0.38095238
## 31  0  0  0  4  0  1 35   0   0   0   0  0.12500000
## 501 0  1  0  0  8  0  0 178   0   0   3  0.06315789
## 502 0  1  0  0  0  0  0   3  15   0   1  0.25000000
## 503 0  5  3  6  0  0  0   0   0 212   6  0.08620690
## 7   0  8  0  0  0  1  0   4   0   8 126  0.14285714
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

ns7

SNA PlanC ns7 15

mn="All_pSNA_PlanC_NS7_pen15" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pSNA_PlanC_NS7_pen15.shp", layer: "All_pSNA_PlanC_NS7_pen15"
## with 129 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 129  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 30.23%
## Confusion matrix:
##     1 20 21 23 3 30 31 501 502 503  7 class.error
## 1   0  0  0  0 1  0  0   0   0   0  0   1.0000000
## 20  0  9  0  0 0  0  0   0   0   4  5   0.5000000
## 21  0  1  3  0 0  0  0   0   0   0  0   0.2500000
## 23  0  0  0  6 0  1  0   0   0   3  0   0.4000000
## 3   0  0  0  0 6  0  0   1   0   0  0   0.1428571
## 30  0  0  0  1 0  0  0   0   0   1  0   1.0000000
## 31  0  0  0  0 0  0  4   0   0   0  0   0.0000000
## 501 0  0  0  0 2  0  0  23   0   0  0   0.0800000
## 502 0  0  0  0 0  0  0   1   2   1  0   0.5000000
## 503 0  4  1  3 0  0  0   0   0  22  1   0.2903226
## 7   0  4  0  0 0  0  0   1   0   3 15   0.3478261
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

SNA PlanC ns7 30

mn="All_pSNA_PlanC_NS7_pen30" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pSNA_PlanC_NS7_pen30.shp", layer: "All_pSNA_PlanC_NS7_pen30"
## with 227 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 227  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 22.03%
## Confusion matrix:
##     1 20 21 23 3 30 31 501 502 503  7 class.error
## 1   0  0  0  0 1  0  0   0   0   0  0  1.00000000
## 20  0 17  1  0 0  0  0   0   0   3  7  0.39285714
## 21  0  2  3  0 0  0  0   0   0   0  0  0.40000000
## 23  0  0  0 15 0  0  1   0   0   3  0  0.21052632
## 3   0  0  0  0 9  0  0   4   0   0  0  0.30769231
## 30  0  0  0  1 0  1  0   0   0   1  0  0.66666667
## 31  0  0  0  1 0  0  6   0   0   0  0  0.14285714
## 501 0  0  0  0 3  0  0  46   0   0  0  0.06122449
## 502 0  1  0  0 0  0  0   2   3   0  0  0.50000000
## 503 0  5  0  2 0  0  0   0   0  48  2  0.15789474
## 7   0  5  0  0 0  0  0   1   0   4 29  0.25641026
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

SNA PlanC ns7 45

mn="All_pSNA_PlanC_NS7_pen45" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pSNA_PlanC_NS7_pen45.shp", layer: "All_pSNA_PlanC_NS7_pen45"
## with 320 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 319  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 20.69%
## Confusion matrix:
##     1 20 21 23  3 30 31 501 502 503  7 class.error
## 1   0  0  0  0  1  0  0   0   0   0  0  1.00000000
## 20  0 18  1  0  0  0  0   0   0   9  7  0.48571429
## 21  0  4  4  0  0  0  0   0   0   0  0  0.50000000
## 23  0  0  0 19  0  0  1   0   0   6  0  0.26923077
## 3   0  0  0  0 13  0  0   6   0   0  0  0.31578947
## 30  0  0  0  1  0  2  0   0   0   1  0  0.50000000
## 31  0  0  0  0  0  0 11   0   0   0  0  0.00000000
## 501 0  0  0  0  4  0  0  69   0   0  0  0.05479452
## 502 0  2  0  0  0  0  0   2   4   0  0  0.50000000
## 503 0  6  0  4  0  0  0   0   0  69  2  0.14814815
## 7   0  4  0  0  0  0  0   1   0   4 44  0.16981132
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

RAN PlanC ns7 15

mn="All_pRAN_PlanC_NS7_pen15" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pRAN_PlanC_NS7_pen15.shp", layer: "All_pRAN_PlanC_NS7_pen15"
## with 129 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 129  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 25.58%
## Confusion matrix:
##     1 20 21 23 3 30 31 501 502 503  7 class.error
## 1   0  0  0  0 1  0  0   0   0   0  0   1.0000000
## 20  0  9  2  0 0  0  0   0   0   1  6   0.5000000
## 21  0  3  0  0 0  0  0   0   1   0  0   1.0000000
## 23  0  0  0  7 0  0  1   0   0   2  0   0.3000000
## 3   0  0  0  0 5  0  0   2   0   0  0   0.2857143
## 30  0  0  0  0 0  2  0   0   0   0  0   0.0000000
## 31  0  0  0  0 0  0  4   0   0   0  0   0.0000000
## 501 0  0  0  0 1  0  0  23   1   0  0   0.0800000
## 502 0  1  0  0 0  0  0   1   2   0  0   0.5000000
## 503 0  2  0  2 0  0  0   0   0  26  1   0.1612903
## 7   0  3  0  0 0  0  0   0   0   2 18   0.2173913
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

RAN PlanC ns7 30

mn="All_pRAN_PlanC_NS7_pen30" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pRAN_PlanC_NS7_pen30.shp", layer: "All_pRAN_PlanC_NS7_pen30"
## with 227 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 227  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 18.5%
## Confusion matrix:
##     1 20 21 23  3 30 31 501 502 503  7 class.error
## 1   0  0  0  0  1  0  0   0   0   0  0  1.00000000
## 20  0 18  1  0  0  0  0   0   0   3  6  0.35714286
## 21  0  2  2  0  0  0  0   0   1   0  0  0.60000000
## 23  0  0  0 14  0  2  0   0   0   3  0  0.26315789
## 3   0  0  0  0 12  0  0   1   0   0  0  0.07692308
## 30  0  0  0  2  0  0  1   0   0   0  0  1.00000000
## 31  0  0  0  1  0  0  6   0   0   0  0  0.14285714
## 501 0  0  0  0  1  0  0  48   0   0  0  0.02040816
## 502 0  1  0  0  0  0  0   2   2   0  1  0.66666667
## 503 0  1  0  1  0  0  0   0   0  53  2  0.07017544
## 7   0  4  0  1  0  0  0   2   0   2 30  0.23076923
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

RAN PlanC ns7 45

mn="All_pRAN_PlanC_NS7_pen45" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pRAN_PlanC_NS7_pen45.shp", layer: "All_pRAN_PlanC_NS7_pen45"
## with 320 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 320  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 17.81%
## Confusion matrix:
##     1 20 21 23  3 30 31 501 502 503  7 class.error
## 1   2  0  0  0  0  0  0   0   0   0  0  0.00000000
## 20  0 26  0  0  0  0  0   0   0   3  6  0.25714286
## 21  0  1  6  0  0  0  0   0   1   0  0  0.25000000
## 23  0  0  0 18  0  2  1   0   0   5  0  0.30769231
## 3   0  0  0  0 15  0  0   4   0   0  0  0.21052632
## 30  0  0  0  4  0  0  0   0   0   0  0  1.00000000
## 31  0  0  0  1  0  0 10   0   0   0  0  0.09090909
## 501 0  0  0  0  2  0  0  69   1   0  1  0.05479452
## 502 0  2  0  0  0  0  0   2   3   0  1  0.62500000
## 503 0  4  0  5  0  0  0   0   0  72  0  0.11111111
## 7   0  5  0  1  0  0  0   1   0   4 42  0.20754717
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

ProfileC -ok

ns3

SNA ProfileC ns3 15

mn="All_pSNA_ProfileC_NS3_pen15" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pSNA_ProfileC_NS3_pen15.shp", layer: "All_pSNA_ProfileC_NS3_pen15"
## with 1000 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 996  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 24.5%
## Confusion matrix:
##     1 20 21 23  3 30 31 501 502 503   7 class.error
## 1   2  0  0  0  1  0  0   0   0   0   0  0.33333333
## 20  0 84 21  0  0  0  0   1   1  31  18  0.46153846
## 21  0 23 31  0  0  0  0   0   0   3   0  0.45614035
## 23  0  0  0 69  0  4  2   0   0  17   5  0.28865979
## 3   1  0  0  0 43  0  0   9   0   0   0  0.18867925
## 30  0  0  0  8  0 19  0   0   0   1   5  0.42424242
## 31  0  0  0  2  0  1 36   0   0   0   0  0.07692308
## 501 0  0  0  0  7  0  0 150   0   0   4  0.06832298
## 502 0  6  0  0  0  0  0   2  11   1   1  0.47619048
## 503 0 25  2  9  0  1  0   0   0 191   5  0.18025751
## 7   0  8  0  1  0  2  0   9   0   7 116  0.18881119
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

SNA ProfileC ns3 30

mn="All_pSNA_ProfileC_NS3_pen30" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pSNA_ProfileC_NS3_pen30.shp", layer: "All_pSNA_ProfileC_NS3_pen30"
## with 1950 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 1946   10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 21.69%
## Confusion matrix:
##     1  20 21  23  3 30 31 501 502 503   7 class.error
## 1   4   0  0   0  4  0  0   0   0   0   0  0.50000000
## 20  0 179 37   0  0  0  0   3   0  51  33  0.40924092
## 21  0  46 53   0  0  0  0   0   0   9   0  0.50925926
## 23  0   0  0 143  0 12  3   0   0  23   5  0.23118280
## 3   2   0  0   0 94  0  0   9   0   0   0  0.10476190
## 30  0   0  0   6  0 46  2   0   0   2   6  0.25806452
## 31  0   0  0   5  0  2 70   0   0   1   0  0.10256410
## 501 0   3  0   0 16  0  0 292   0   0  10  0.09034268
## 502 0   3  0   0  0  0  0   3  31   1   2  0.22500000
## 503 0  41  2  13  0  1  0   0   0 394   7  0.13973799
## 7   0  19  0   2  0  1  0  24   1  12 218  0.21299639
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

SNA ProfileC ns3 45

mn="All_pSNA_ProfileC_NS3_pen45" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pSNA_ProfileC_NS3_pen45.shp", layer: "All_pSNA_ProfileC_NS3_pen45"
## with 2899 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 2895   10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 19.45%
## Confusion matrix:
##      1  20 21  23   3 30  31 501 502 503   7 class.error
## 1   10   0  0   0   3  0   0   0   0   0   0  0.23076923
## 20   0 288 48   0   0  0   0   7   0  70  36  0.35857461
## 21   0  56 89   0   0  0   0   0   0  14   1  0.44375000
## 23   0   0  0 228   0 11   3   0   0  28   4  0.16788321
## 3    4   0  0   0 140  0   0  13   0   0   0  0.10828025
## 30   0   0  0   8   0 71   2   0   0   4   6  0.21978022
## 31   0   0  0   5   0  6 105   0   0   1   0  0.10256410
## 501  0   4  0   0  25  0   0 436   0   0  16  0.09355509
## 502  0   1  1   0   0  0   0   3  46   4   2  0.19298246
## 503  0  57  3  17   0  4   0   0   2 590  12  0.13868613
## 7    0  28  1   3   0  2   0  33   1  14 329  0.19951338
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

RAN ProfileC ns3 15

mn="All_pRAN_ProfileC_NS3_pen15" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pRAN_ProfileC_NS3_pen15.shp", layer: "All_pRAN_ProfileC_NS3_pen15"
## with 1000 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 998  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 25.75%
## Confusion matrix:
##     1 20 21 23  3 30 31 501 502 503   7 class.error
## 1   4  0  0  0  1  0  0   0   0   0   0   0.2000000
## 20  0 94 19  1  0  0  0   1   1  28  12   0.3974359
## 21  0 30 25  0  0  0  0   0   0   2   0   0.5614035
## 23  0  0  0 64  0 10  3   0   0  17   3   0.3402062
## 3   0  0  0  0 39  0  0  14   0   0   0   0.2641509
## 30  0  0  0  7  0 20  5   0   0   0   1   0.3939394
## 31  0  0  0  6  0  4 29   0   0   0   0   0.2564103
## 501 0  1  0  0 10  0  0 141   2   0   7   0.1242236
## 502 0  3  0  0  0  0  0   3  13   0   2   0.3809524
## 503 0 19  2  6  0  0  0   0   1 200   5   0.1416309
## 7   0 12  0  1  0  2  0   6   1   9 112   0.2167832
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

RAN ProfileC ns3 30

mn="All_pRAN_ProfileC_NS3_pen30" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pRAN_ProfileC_NS3_pen30.shp", layer: "All_pRAN_ProfileC_NS3_pen30"
## with 1950 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 1946   10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 22.1%
## Confusion matrix:
##     1  20 21  23  3 30 31 501 502 503   7 class.error
## 1   7   0  0   0  1  0  0   0   0   0   0  0.12500000
## 20  0 220 23   2  0  1  0   3   1  34  19  0.27392739
## 21  0  46 56   0  0  0  0   0   1   4   1  0.48148148
## 23  0   2  0 132  0 16  4   0   0  25   7  0.29032258
## 3   0   0  0   0 78  0  0  27   0   0   0  0.25714286
## 30  0   0  0  13  0 40  5   0   0   1   3  0.35483871
## 31  0   0  0  11  0  3 64   0   0   0   0  0.17948718
## 501 0   0  0   0 16  0  0 297   1   0   7  0.07476636
## 502 0   6  1   0  0  0  0   2  27   0   4  0.32500000
## 503 0  38  2  23  0  1  0   0   1 380  13  0.17030568
## 7   0  26  0   4  0  2  0  15   2  13 215  0.22382671
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

RAN ProfileC ns3 45

mn="All_pRAN_ProfileC_NS3_pen45" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pRAN_ProfileC_NS3_pen45.shp", layer: "All_pRAN_ProfileC_NS3_pen45"
## with 2899 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 2894   10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 19.38%
## Confusion matrix:
##      1  20 21  23   3 30  31 501 502 503   7 class.error
## 1   11   0  0   0   1  0   0   0   0   0   0  0.08333333
## 20   0 329 23   1   0  0   0   6   2  61  27  0.26726058
## 21   0  56 93   0   0  0   0   1   0   8   2  0.41875000
## 23   0   0  0 202   0 24   4   0   0  37   7  0.26277372
## 3    1   0  0   0 121  0   0  35   0   0   0  0.22929936
## 30   0   0  0  20   0 64   5   0   0   0   2  0.29670330
## 31   0   0  0  13   0  3 100   0   0   1   0  0.14529915
## 501  0   6  1   0  24  0   0 438   1   0  11  0.08939709
## 502  0   3  1   0   0  0   0   2  44   1   6  0.22807018
## 503  0  44  1  23   0  2   0   0   1 597  17  0.12846715
## 7    0  27  0   1   0  5   0  24   1  19 334  0.18734793
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

ns5

SNA ProfileC ns5 15

mn="All_pSNA_ProfileC_NS5_pen15" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pSNA_ProfileC_NS5_pen15.shp", layer: "All_pSNA_ProfileC_NS5_pen15"
## with 340 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 338  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 26.33%
## Confusion matrix:
##     20 21 23  3 30 31 501 502 503  7 class.error
## 20  26  5  0  0  0  0   0   0   7  8  0.43478261
## 21  15  6  0  0  0  0   0   0   2  0  0.73913043
## 23   0  0 19  0  2  0   0   0   6  1  0.32142857
## 3    0  0  0 16  0  0   2   0   0  0  0.11111111
## 30   0  0  3  0  5  0   0   0   0  1  0.44444444
## 31   0  0  0  0  0 14   0   0   0  0  0.00000000
## 501  0  0  0  4  0  0  54   0   0  1  0.08474576
## 502  1  0  0  0  0  0   1   4   0  1  0.42857143
## 503  7  3  2  0  0  0   0   0  67  3  0.18292683
## 7    3  0  1  0  1  0   4   0   5 38  0.26923077
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

SNA ProfileC ns5 30

mn="All_pSNA_ProfileC_NS5_pen30" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pSNA_ProfileC_NS5_pen30.shp", layer: "All_pSNA_ProfileC_NS5_pen30"
## with 638 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 636  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 21.54%
## Confusion matrix:
##     1 20 21 23  3 30 31 501 502 503  7 class.error
## 1   0  0  0  0  2  0  0   0   0   0  0  1.00000000
## 20  0 47  9  0  0  0  0   0   0  16 12  0.44047619
## 21  0 14 19  0  0  0  0   0   0   2  0  0.45714286
## 23  0  0  0 43  0  2  2   0   0   5  1  0.18867925
## 3   1  0  0  0 30  0  0   4   0   0  0  0.14285714
## 30  0  0  0  3  0 12  0   0   0   0  0  0.20000000
## 31  0  0  0  1  0  0 26   0   0   0  0  0.03703704
## 501 0  0  0  0  6  0  0 108   1   0  2  0.07692308
## 502 0  2  0  0  0  0  0   3   7   0  2  0.50000000
## 503 0 12  2  3  0  0  0   0   0 135  6  0.14556962
## 7   0  4  0  0  0  2  0   9   0   9 72  0.25000000
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

SNA ProfileC ns5 45

mn="All_pSNA_ProfileC_NS5_pen45" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pSNA_ProfileC_NS5_pen45.shp", layer: "All_pSNA_ProfileC_NS5_pen45"
## with 936 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 934  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 19.27%
## Confusion matrix:
##     1 20 21 23  3 30 31 501 502 503   7 class.error
## 1   3  0  0  0  0  0  0   0   0   0   0  0.00000000
## 20  0 72 12  0  0  0  0   0   0  21  16  0.40495868
## 21  0 18 27  0  0  0  0   0   0   2   1  0.43750000
## 23  0  0  0 61  0  3  3   0   0   9   2  0.21794872
## 3   0  0  0  0 46  0  0   6   0   0   0  0.11538462
## 30  0  0  0  6  0 16  0   0   0   0   0  0.27272727
## 31  0  0  0  2  0  0 39   0   0   0   0  0.04878049
## 501 0  2  0  0  9  0  0 162   0   0   2  0.07428571
## 502 0  3  0  0  1  0  0   2  11   1   2  0.45000000
## 503 0 14  3  5  0  0  0   0   0 208   5  0.11489362
## 7   0  8  0  1  0  2  0  11   1   7 109  0.21582734
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

RAN ProfileC ns5 15

mn="All_pRAN_ProfileC_NS5_pen15" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pRAN_ProfileC_NS5_pen15.shp", layer: "All_pRAN_ProfileC_NS5_pen15"
## with 340 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 340  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 22.65%
## Confusion matrix:
##     1 20 21 23  3 30 31 501 502 503  7 class.error
## 1   0  0  0  0  2  0  0   0   0   0  0  1.00000000
## 20  0 25  7  0  0  0  0   0   1   8  5  0.45652174
## 21  0  6 16  0  0  0  0   0   0   1  0  0.30434783
## 23  0  0  0 20  0  3  1   0   0   3  1  0.28571429
## 3   0  0  0  0 15  0  0   3   0   0  0  0.16666667
## 30  0  0  0  3  0  5  0   0   0   0  1  0.44444444
## 31  0  0  0  3  0  0 11   0   0   0  0  0.21428571
## 501 0  0  0  0  5  0  0  52   1   0  1  0.11864407
## 502 0  2  0  0  0  0  0   2   2   0  1  0.71428571
## 503 0  4  0  2  0  1  0   0   0  74  1  0.09756098
## 7   0  3  0  0  0  0  0   1   0   5 43  0.17307692
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

RAN ProfileC ns5 30

mn="All_pRAN_ProfileC_NS5_pen30" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pRAN_ProfileC_NS5_pen30.shp", layer: "All_pRAN_ProfileC_NS5_pen30"
## with 638 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 638  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 18.5%
## Confusion matrix:
##     1 20 21 23  3 30 31 501 502 503  7 class.error
## 1   3  0  0  0  1  0  0   0   0   0  0  0.25000000
## 20  0 55  7  0  0  0  0   1   0   9 12  0.34523810
## 21  0 13 21  0  0  0  0   0   0   1  0  0.40000000
## 23  0  0  0 40  0  2  1   0   0   9  1  0.24528302
## 3   0  0  0  0 30  0  0   5   0   0  0  0.14285714
## 30  0  0  0  1  0 12  1   0   0   0  1  0.20000000
## 31  0  0  0  3  0  0 24   0   0   0  0  0.11111111
## 501 0  0  0  0  6  0  0 109   0   0  2  0.06837607
## 502 0  4  0  0  0  0  0   0   9   0  1  0.35714286
## 503 0  8  1  6  0  0  0   0   0 137  6  0.13291139
## 7   0  7  0  0  0  1  0   3   0   5 80  0.16666667
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

RAN ProfileC ns5 45

mn="All_pRAN_ProfileC_NS5_pen45" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pRAN_ProfileC_NS5_pen45.shp", layer: "All_pRAN_ProfileC_NS5_pen45"
## with 936 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 936  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 19.12%
## Confusion matrix:
##     1 20 21 23  3 30 31 501 502 503   7 class.error
## 1   3  0  0  0  2  0  0   0   0   0   0  0.40000000
## 20  0 83  9  0  0  0  0   1   0  13  15  0.31404959
## 21  0 11 33  0  0  0  0   0   1   3   0  0.31250000
## 23  0  0  0 52  0  7  3   0   0  14   2  0.33333333
## 3   1  0  0  0 42  0  0   9   0   0   0  0.19230769
## 30  0  0  0  5  0 14  0   0   0   0   3  0.36363636
## 31  0  0  0  4  0  0 37   0   0   0   0  0.09756098
## 501 0  0  0  0  9  0  0 164   1   0   1  0.06285714
## 502 0  4  2  0  0  0  0   2  11   0   1  0.45000000
## 503 0 11  2  7  0  0  0   0   0 210   5  0.10638298
## 7   0 11  0  3  0  3  0   6   0   8 108  0.22302158
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

ns7

SNA ProfileC ns7 15

mn="All_pSNA_ProfileC_NS7_pen15" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pSNA_ProfileC_NS7_pen15.shp", layer: "All_pSNA_ProfileC_NS7_pen15"
## with 122 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 122  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 31.15%
## Confusion matrix:
##     1 20 21 23 3 30 31 501 502 503  7 class.error
## 1   0  0  0  0 1  0  0   0   0   0  0   1.0000000
## 20  0 10  1  0 0  0  0   0   0   3  3   0.4117647
## 21  0  3  1  0 0  0  0   0   0   0  0   0.7500000
## 23  0  0  0  9 0  0  0   0   0   1  0   0.1000000
## 3   0  0  0  0 4  0  0   2   0   0  0   0.3333333
## 30  0  0  0  1 0  2  0   0   0   0  0   0.3333333
## 31  0  0  0  0 0  0  4   0   0   0  0   0.0000000
## 501 0  1  0  0 1  0  0  21   0   0  1   0.1250000
## 502 0  1  0  0 0  0  0   2   0   0  1   1.0000000
## 503 0  5  1  1 0  0  0   1   0  19  2   0.3448276
## 7   0  2  0  1 0  0  0   1   0   2 14   0.3000000
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

SNA ProfileC ns7 30

mn="All_pSNA_ProfileC_NS7_pen30" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pSNA_ProfileC_NS7_pen30.shp", layer: "All_pSNA_ProfileC_NS7_pen30"
## with 215 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 215  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 21.4%
## Confusion matrix:
##     1 20 21 23 3 30 31 501 502 503  7 class.error
## 1   0  0  0  0 1  0  0   0   0   0  0  1.00000000
## 20  0 17  2  0 0  0  0   0   0   3  3  0.32000000
## 21  0  4  3  0 0  0  0   0   0   0  0  0.57142857
## 23  0  0  0 13 0  0  0   0   0   5  0  0.27777778
## 3   0  0  0  0 9  0  0   3   0   0  0  0.25000000
## 30  0  0  0  2 0  2  0   0   0   0  0  0.50000000
## 31  0  0  0  0 0  0  7   0   0   0  0  0.00000000
## 501 0  0  0  0 3  0  0  43   0   0  1  0.08510638
## 502 0  1  0  0 1  0  0   1   2   1  0  0.66666667
## 503 0  2  1  1 0  0  0   0   0  44  5  0.16981132
## 7   0  0  0  1 0  0  0   2   0   3 29  0.17142857
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

SNA ProfileC ns7 45

mn="All_pSNA_ProfileC_NS7_pen45" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pSNA_ProfileC_NS7_pen45.shp", layer: "All_pSNA_ProfileC_NS7_pen45"
## with 307 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 307  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 15.96%
## Confusion matrix:
##     1 20 21 23  3 30 31 501 502 503  7 class.error
## 1   2  0  0  0  0  0  0   0   0   0  0  0.00000000
## 20  0 21  1  0  0  0  0   0   1   5  3  0.32258065
## 21  0  4  4  0  0  0  0   0   0   0  0  0.50000000
## 23  0  0  0 21  0  0  0   0   0   5  0  0.19230769
## 3   0  0  0  0 15  0  0   3   0   0  0  0.16666667
## 30  0  0  0  1  0  3  1   0   0   0  0  0.40000000
## 31  0  0  0  0  0  0 11   0   0   0  0  0.00000000
## 501 0  0  0  0  2  0  0  67   0   0  1  0.04285714
## 502 0  1  0  0  0  0  0   3   1   1  2  0.87500000
## 503 0  2  1  3  0  0  0   0   0  70  3  0.11392405
## 7   0  1  0  1  0  0  0   1   0   3 43  0.12244898
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

RAN ProfileC ns7 15

mn="All_pRAN_ProfileC_NS7_pen15" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pRAN_ProfileC_NS7_pen15.shp", layer: "All_pRAN_ProfileC_NS7_pen15"
## with 122 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 122  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 27.87%
## Confusion matrix:
##     1 20 21 23 3 30 31 501 502 503  7 class.error
## 1   0  0  0  0 1  0  0   0   0   0  0  1.00000000
## 20  0 11  0  0 0  0  0   0   0   1  5  0.35294118
## 21  0  2  0  0 0  0  0   0   2   0  0  1.00000000
## 23  0  0  0  5 0  2  0   0   0   3  0  0.50000000
## 3   0  0  0  0 5  0  0   1   0   0  0  0.16666667
## 30  0  0  0  0 0  2  0   0   0   1  0  0.33333333
## 31  0  0  0  1 0  0  3   0   0   0  0  0.25000000
## 501 0  0  0  0 0  0  0  22   1   0  1  0.08333333
## 502 0  1  0  0 0  0  0   1   2   0  0  0.50000000
## 503 0  1  1  3 0  0  0   0   0  23  1  0.20689655
## 7   0  3  0  0 0  0  0   1   0   1 15  0.25000000
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

RAN ProfileC ns7 30

mn="All_pRAN_ProfileC_NS7_pen30" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pRAN_ProfileC_NS7_pen30.shp", layer: "All_pRAN_ProfileC_NS7_pen30"
## with 215 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 215  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 18.14%
## Confusion matrix:
##     1 20 21 23 3 30 31 501 502 503  7 class.error
## 1   0  0  0  0 1  0  0   0   0   0  0  1.00000000
## 20  0 19  1  0 0  0  0   0   0   2  3  0.24000000
## 21  0  2  5  0 0  0  0   0   0   0  0  0.28571429
## 23  0  0  0 12 0  2  0   0   0   4  0  0.33333333
## 3   0  0  0  0 8  0  0   4   0   0  0  0.33333333
## 30  0  0  0  2 0  2  0   0   0   0  0  0.50000000
## 31  0  0  0  0 0  0  7   0   0   0  0  0.00000000
## 501 0  1  0  0 2  0  0  44   0   0  0  0.06382979
## 502 0  2  0  0 1  0  0   2   1   0  0  0.83333333
## 503 0  2  0  2 0  0  0   0   0  48  1  0.09433962
## 7   0  2  0  1 0  0  0   0   0   2 30  0.14285714
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

RAN ProfileC ns7 45

mn="All_pRAN_ProfileC_NS7_pen45" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pRAN_ProfileC_NS7_pen45.shp", layer: "All_pRAN_ProfileC_NS7_pen45"
## with 307 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 307  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 15.64%
## Confusion matrix:
##     1 20 21 23  3 30 31 501 502 503  7 class.error
## 1   1  0  0  0  1  0  0   0   0   0  0  0.50000000
## 20  0 21  1  0  0  0  0   0   0   2  7  0.32258065
## 21  0  3  5  0  0  0  0   0   0   0  0  0.37500000
## 23  0  0  0 19  0  2  1   0   0   4  0  0.26923077
## 3   0  0  0  0 15  0  0   3   0   0  0  0.16666667
## 30  0  0  0  3  0  2  0   0   0   0  0  0.60000000
## 31  0  0  0  0  0  0 11   0   0   0  0  0.00000000
## 501 0  1  0  0  2  0  0  67   0   0  0  0.04285714
## 502 0  1  0  0  0  0  0   4   3   0  0  0.62500000
## 503 0  1  1  2  0  0  0   0   0  74  1  0.06329114
## 7   0  6  0  0  0  0  0   0   0   2 41  0.16326531
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

TWI -ok

ns3

SNA TWI ns3 15

mn="All_pSNA_TWI_NS3_pen15" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pSNA_TWI_NS3_pen15.shp", layer: "All_pSNA_TWI_NS3_pen15"
## with 985 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 983  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 22.69%
## Confusion matrix:
##     1 20 21 23  3 30 31 501 502 503   7 class.error
## 1   6  0  0  0  0  0  0   0   0   0   0  0.00000000
## 20  0 87 15  1  0  0  0   1   0  31  16  0.42384106
## 21  0 23 23  0  0  0  0   0   0   7   2  0.58181818
## 23  0  0  0 90  0  2  1   0   0   7   1  0.10891089
## 3   0  0  0  0 36  0  0  14   0   0   0  0.28000000
## 30  0  0  0  5  0 23  3   0   0   0   2  0.30303030
## 31  0  0  0  0  0  1 41   0   0   0   0  0.02380952
## 501 0  1  0  0 10  0  0 141   2   0   3  0.10191083
## 502 0  1  0  0  0  0  0   3  14   0   2  0.30000000
## 503 0 25  4  9  0  0  0   0   0 187   3  0.17982456
## 7   0 13  1  1  0  1  0   6   1   5 112  0.20000000
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

SNA TWI ns3 30

mn="All_pSNA_TWI_NS3_pen30" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pSNA_TWI_NS3_pen30.shp", layer: "All_pSNA_TWI_NS3_pen30"
## with 1921 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 1919   10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 21.57%
## Confusion matrix:
##     1  20 21  23  3 30 31 501 502 503   7 class.error
## 1   9   0  0   0  2  0  0   0   0   0   0   0.1818182
## 20  0 183 24   2  0  0  0   1   0  53  31   0.3775510
## 21  0  38 52   0  0  0  0   0   1  12   1   0.5000000
## 23  0   1  0 166  0  7  5   0   0  14   0   0.1398964
## 3   3   0  0   0 68  0  0  28   0   0   0   0.3131313
## 30  0   0  0  13  0 40  3   0   0   0   7   0.3650794
## 31  0   0  0   7  0  1 74   0   0   1   0   0.1084337
## 501 0   1  0   0 26  0  0 276   2   0   8   0.1182109
## 502 0   3  0   0  0  0  0   2  28   0   5   0.2631579
## 503 0  36  6  19  0  0  0   0   0 385   3   0.1425390
## 7   0  18  1   1  0  4  0  12   4   8 224   0.1764706
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

SNA TWI ns3 45

mn="All_pSNA_TWI_NS3_pen45" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pSNA_TWI_NS3_pen45.shp", layer: "All_pSNA_TWI_NS3_pen45"
## with 2859 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 2857   10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 20.48%
## Confusion matrix:
##      1  20 21  23   3 30  31 501 502 503   7 class.error
## 1   13   0  0   0   3  0   0   0   0   0   0   0.1875000
## 20   0 275 33   2   0  0   0   4   3  72  47   0.3692661
## 21   0  50 90   0   0  0   0   0   3  12   1   0.4230769
## 23   0   1  0 239   0 11   9   0   0  22   4   0.1643357
## 3    3   0  0   0 102  0   0  42   0   0   0   0.3061224
## 30   0   0  0  12   0 69   4   0   0   0   6   0.2417582
## 31   0   0  0  10   0  4 110   0   0   0   0   0.1129032
## 501  0   2  0   0  31  0   0 414   1   0  21   0.1172708
## 502  0   2  1   0   0  0   0   2  41   0   8   0.2407407
## 503  0  52  6  24   0  1   0   0   0 579  10   0.1383929
## 7    0  22  1   1   0  4   0  21   4  13 340   0.1625616
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

RAN TWI ns3 15

mn="All_pRAN_TWI_NS3_pen15" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pRAN_TWI_NS3_pen15.shp", layer: "All_pRAN_TWI_NS3_pen15"
## with 985 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 983  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 27.47%
## Confusion matrix:
##     1 20 21 23  3 30 31 501 502 503   7 class.error
## 1   5  0  0  0  1  0  0   0   0   0   0   0.1666667
## 20  0 86 21  1  0  0  0   3   0  26  14   0.4304636
## 21  0 25 27  0  0  0  0   1   1   1   0   0.5090909
## 23  0  0  0 65  0  9  3   0   0  19   5   0.3564356
## 3   0  0  0  0 37  0  0  13   0   0   0   0.2600000
## 30  0  0  0 11  0 17  4   0   0   0   1   0.4848485
## 31  0  0  0  8  0  2 32   0   0   0   0   0.2380952
## 501 0  0  0  0 11  0  0 138   0   0   8   0.1210191
## 502 0  5  0  0  0  0  0   4   9   1   1   0.5500000
## 503 0 16  0 11  0  1  0   0   1 193   6   0.1535088
## 7   0 12  0  2  0  3  0   8   2   9 104   0.2571429
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

RAN TWI ns3 30

mn="All_pRAN_TWI_NS3_pen30" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pRAN_TWI_NS3_pen30.shp", layer: "All_pRAN_TWI_NS3_pen30"
## with 1921 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 1918   10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 21.64%
## Confusion matrix:
##     1  20 21  23  3 30 31 501 502 503   7 class.error
## 1   8   0  0   0  2  0  0   0   0   0   0   0.2000000
## 20  0 203 23   0  0  0  0   2   0  37  29   0.3095238
## 21  0  45 52   0  0  0  0   1   1   4   1   0.5000000
## 23  0   0  0 139  0 12  6   0   0  27   9   0.2797927
## 3   2   0  0   0 78  0  0  19   0   0   0   0.2121212
## 30  0   0  0  14  0 45  3   0   0   0   1   0.2857143
## 31  0   0  0  11  0  3 69   0   0   0   0   0.1686747
## 501 0   5  0   0 15  0  0 288   1   0   4   0.0798722
## 502 0   4  0   0  0  0  0   1  30   0   3   0.2105263
## 503 0  35  3  16  0  0  0   0   0 385  10   0.1425390
## 7   0  23  1   4  0  3  0  16   2  17 206   0.2426471
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

RAN TWI ns3 45

mn="All_pRAN_TWI_NS3_pen45" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pRAN_TWI_NS3_pen45.shp", layer: "All_pRAN_TWI_NS3_pen45"
## with 2859 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 2855   10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 19.02%
## Confusion matrix:
##      1  20 21  23   3 30  31 501 502 503   7 class.error
## 1   13   0  0   0   1  0   0   0   0   0   0  0.07142857
## 20   0 305 36   2   0  0   0   2   2  61  28  0.30045872
## 21   0  53 94   0   0  0   0   0   2   6   1  0.39743590
## 23   0   0  0 212   0 17   9   0   0  36  12  0.25874126
## 3    1   0  0   0 117  0   0  29   0   0   0  0.20408163
## 30   0   0  0  20   0 65   3   0   0   0   3  0.28571429
## 31   0   0  0  14   0  3 107   0   0   0   0  0.13709677
## 501  0   3  0   0  14  0   0 440   0   0  12  0.06183369
## 502  0   2  0   0   0  0   0   0  50   2   0  0.07407407
## 503  0  56  4  27   0  0   0   0   1 572  12  0.14880952
## 7    0  28  0   6   0  3   0  10   3  19 337  0.16995074
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

ns5

SNA TWI ns5 15

mn="All_pSNA_TWI_NS5_pen15" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pSNA_TWI_NS5_pen15.shp", layer: "All_pSNA_TWI_NS5_pen15"
## with 337 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 337  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 21.36%
## Confusion matrix:
##     1 20 21 23 3 30 31 501 502 503  7 class.error
## 1   2  0  0  0 0  0  0   0   0   0  0  0.00000000
## 20  0 24  4  0 0  0  0   0   0  10  6  0.45454545
## 21  0  6 13  1 0  0  0   0   0   2  0  0.40909091
## 23  0  0  0 24 0  1  1   0   0   3  0  0.17241379
## 3   0  0  0  0 9  0  0   8   0   0  0  0.47058824
## 30  0  0  0  3 0  3  2   0   0   0  1  0.66666667
## 31  0  0  0  0 0  1 13   0   0   0  0  0.07142857
## 501 0  0  0  0 4  0  0  54   0   0  1  0.08474576
## 502 0  1  0  0 0  0  0   2   4   0  0  0.42857143
## 503 0  2  2  2 0  0  0   0   0  74  1  0.08641975
## 7   0  4  0  1 0  0  0   1   0   2 45  0.15094340
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

SNA TWI ns5 30

mn="All_pSNA_TWI_NS5_pen30" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pSNA_TWI_NS5_pen30.shp", layer: "All_pSNA_TWI_NS5_pen30"
## with 634 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 634  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 22.71%
## Confusion matrix:
##     1 20 21 23  3 30 31 501 502 503  7 class.error
## 1   3  0  0  0  1  0  0   0   0   0  0   0.2500000
## 20  0 40 11  0  0  0  0   0   0  18 13   0.5121951
## 21  0 10 17  0  0  0  0   0   2   3  0   0.4687500
## 23  0  0  0 44  0  3  1   0   0   6  0   0.1851852
## 3   1  0  0  0 19  0  0  14   0   0  0   0.4411765
## 30  0  0  0  3  0  7  3   0   0   0  2   0.5333333
## 31  0  0  0  2  0  3 22   0   0   1  0   0.2142857
## 501 0  0  0  0 10  0  0 105   0   0  2   0.1025641
## 502 0  1  0  0  0  0  0   1  10   0  2   0.2857143
## 503 0  6  2  7  0  0  0   0   0 137  3   0.1161290
## 7   0  6  1  0  0  0  0   3   1   2 86   0.1313131
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

SNA TWI ns5 45

mn="All_pSNA_TWI_NS5_pen45" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pSNA_TWI_NS5_pen45.shp", layer: "All_pSNA_TWI_NS5_pen45"
## with 934 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 934  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 19.49%
## Confusion matrix:
##     1 20 21 23  3 30 31 501 502 503   7 class.error
## 1   5  0  0  0  1  0  0   0   0   0   0   0.1666667
## 20  0 68 12  0  0  0  0   1   1  19  17   0.4237288
## 21  0 15 27  0  0  0  0   0   0   3   0   0.4000000
## 23  0  0  0 66  0  2  4   0   0   9   0   0.1851852
## 3   1  0  0  0 35  0  0  14   0   0   0   0.3000000
## 30  0  0  0  2  0 13  5   0   0   0   2   0.4090909
## 31  0  0  0  3  0  3 35   0   0   1   0   0.1666667
## 501 0  0  0  0 16  0  0 155   0   0   4   0.1142857
## 502 0  1  0  0  0  0  0   2  13   0   3   0.3157895
## 503 0  9  2  9  0  0  0   0   0 209   2   0.0952381
## 7   0  9  1  0  0  0  0   5   0   4 126   0.1310345
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

RAN TWI ns5 15

mn="All_pRAN_TWI_NS5_pen15" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pRAN_TWI_NS5_pen15.shp", layer: "All_pRAN_TWI_NS5_pen15"
## with 337 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 337  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 23.15%
## Confusion matrix:
##     1 20 21 23  3 30 31 501 502 503  7 class.error
## 1   1  0  0  0  1  0  0   0   0   0  0   0.5000000
## 20  0 26  6  0  0  0  0   1   1   2  8   0.4090909
## 21  0  8 13  0  0  0  0   0   0   1  0   0.4090909
## 23  0  0  0 22  0  3  1   0   0   3  0   0.2413793
## 3   0  0  0  0 11  0  0   5   1   0  0   0.3529412
## 30  0  0  0  4  0  4  0   0   0   0  1   0.5555556
## 31  0  0  0  0  0  0 14   0   0   0  0   0.0000000
## 501 0  0  0  0  6  0  0  52   0   0  1   0.1186441
## 502 0  2  1  0  0  0  0   1   3   0  0   0.5714286
## 503 0  2  1  6  0  0  0   0   0  69  3   0.1481481
## 7   0  6  0  0  0  0  0   1   0   2 44   0.1698113
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

RAN TWI ns5 30

mn="All_pRAN_TWI_NS5_pen30" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pRAN_TWI_NS5_pen30.shp", layer: "All_pRAN_TWI_NS5_pen30"
## with 634 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 634  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 18.45%
## Confusion matrix:
##     1 20 21 23  3 30 31 501 502 503  7 class.error
## 1   2  0  0  0  2  0  0   0   0   0  0  0.50000000
## 20  0 57  5  0  0  0  0   2   0  10  8  0.30487805
## 21  0 15 15  0  0  0  0   0   0   2  0  0.53125000
## 23  0  0  0 39  0  4  2   0   0   7  2  0.27777778
## 3   1  0  0  0 28  0  0   5   0   0  0  0.17647059
## 30  0  0  0  4  0  9  1   0   0   0  1  0.40000000
## 31  0  0  0  2  0  0 25   0   0   1  0  0.10714286
## 501 0  2  0  0  8  0  0 105   1   0  1  0.10256410
## 502 0  2  0  0  0  0  0   1   9   1  1  0.35714286
## 503 0  6  1  4  0  0  0   0   0 142  2  0.08387097
## 7   0  6  0  0  0  0  0   1   0   6 86  0.13131313
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

RAN TWI ns5 45

mn="All_pRAN_TWI_NS5_pen45" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pRAN_TWI_NS5_pen45.shp", layer: "All_pRAN_TWI_NS5_pen45"
## with 934 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 934  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 16.81%
## Confusion matrix:
##     1 20 21 23  3 30 31 501 502 503   7 class.error
## 1   5  0  0  0  1  0  0   0   0   0   0  0.16666667
## 20  0 79  8  0  0  0  0   1   1  15  14  0.33050847
## 21  0 16 28  0  0  0  0   0   0   1   0  0.37777778
## 23  0  0  0 61  0  6  2   0   0   9   3  0.24691358
## 3   0  0  0  0 41  0  0   9   0   0   0  0.18000000
## 30  0  0  0  7  0 12  1   0   0   0   2  0.45454545
## 31  0  0  0  0  0  1 41   0   0   0   0  0.02380952
## 501 0  1  0  0  5  0  0 165   0   0   4  0.05714286
## 502 0  2  0  0  0  0  0   3  13   0   1  0.31578947
## 503 0  6  0  8  0  0  0   0   0 213   4  0.07792208
## 7   0  8  0  1  0  1  0   6   1   9 119  0.17931034
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

ns7

SNA TWI ns7 15

mn="All_pSNA_TWI_NS7_pen15" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pSNA_TWI_NS7_pen15.shp", layer: "All_pSNA_TWI_NS7_pen15"
## with 122 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 122  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 27.87%
## Confusion matrix:
##     1 20 21 23 3 30 31 501 502 503  7 class.error
## 1   0  0  0  0 1  0  0   0   0   0  0  1.00000000
## 20  0  8  1  0 0  0  0   0   0   5  3  0.52941176
## 21  0  2  2  0 0  0  0   0   0   0  0  0.50000000
## 23  0  0  0  6 0  2  0   0   0   3  0  0.45454545
## 3   0  0  0  0 5  0  0   2   0   0  0  0.28571429
## 30  0  0  0  2 0  1  0   0   0   0  0  0.66666667
## 31  0  0  0  0 0  0  4   0   0   0  0  0.00000000
## 501 0  0  0  0 1  0  0  22   0   0  0  0.04347826
## 502 0  0  0  0 0  0  0   3   0   0  0  1.00000000
## 503 0  3  0  1 0  0  0   0   0  25  0  0.13793103
## 7   0  2  0  1 0  0  0   1   0   1 15  0.25000000
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

SNA TWI ns7 30

mn="All_pSNA_TWI_NS7_pen30" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pSNA_TWI_NS7_pen30.shp", layer: "All_pSNA_TWI_NS7_pen30"
## with 216 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 216  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 18.52%
## Confusion matrix:
##     1 20 21 23  3 30 31 501 502 503  7 class.error
## 1   0  0  0  0  1  0  0   0   0   0  0  1.00000000
## 20  0 12  2  0  0  0  0   0   0   7  5  0.53846154
## 21  0  2  4  0  0  0  0   0   0   0  0  0.33333333
## 23  0  0  0 16  0  1  0   0   0   3  0  0.20000000
## 3   0  0  0  0 10  0  0   3   0   0  0  0.23076923
## 30  0  0  0  1  0  3  0   0   0   0  0  0.25000000
## 31  0  0  0  1  0  0  6   0   0   0  0  0.14285714
## 501 0  0  0  0  2  0  0  43   0   0  0  0.04444444
## 502 0  0  0  0  0  0  0   2   3   0  0  0.40000000
## 503 0  4  0  2  0  0  0   0   0  48  0  0.11111111
## 7   0  2  0  0  0  0  0   0   0   2 31  0.11428571
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

SNA TWI ns7 45

mn="All_pSNA_TWI_NS7_pen45" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pSNA_TWI_NS7_pen45.shp", layer: "All_pSNA_TWI_NS7_pen45"
## with 310 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 310  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 19.35%
## Confusion matrix:
##     1 20 21 23  3 30 31 501 502 503  7 class.error
## 1   0  0  0  0  2  0  0   0   0   0  0  1.00000000
## 20  0 19  1  0  0  0  0   0   0   7  7  0.44117647
## 21  0  3  5  0  0  0  0   0   0   0  0  0.37500000
## 23  0  0  0 20  0  1  1   0   0   5  0  0.25925926
## 3   1  0  0  0 11  0  0   7   0   0  0  0.42105263
## 30  0  0  0  1  0  3  1   0   0   0  0  0.40000000
## 31  0  0  0  0  0  1 10   0   0   0  0  0.09090909
## 501 0  0  0  0  3  0  0  62   0   0  2  0.07462687
## 502 0  0  0  0  0  0  0   3   4   0  0  0.42857143
## 503 0  3  0  1  0  0  0   0   0  73  2  0.07594937
## 7   0  3  0  0  0  0  0   2   0   3 43  0.15686275
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

RAN TWI ns7 15

mn="All_pRAN_TWI_NS7_pen15" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pRAN_TWI_NS7_pen15.shp", layer: "All_pRAN_TWI_NS7_pen15"
## with 122 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 122  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 26.23%
## Confusion matrix:
##     1 20 21 23 3 30 31 501 502 503  7 class.error
## 1   0  0  0  0 1  0  0   0   0   0  0   1.0000000
## 20  0 11  0  0 0  0  0   0   0   3  3   0.3529412
## 21  0  2  2  0 0  0  0   0   0   0  0   0.5000000
## 23  0  0  0  9 0  1  1   0   0   0  0   0.1818182
## 3   0  0  0  0 5  0  0   2   0   0  0   0.2857143
## 30  0  0  0  2 0  0  0   0   0   0  1   1.0000000
## 31  0  0  0  1 0  0  3   0   0   0  0   0.2500000
## 501 0  0  0  0 2  0  0  20   0   0  1   0.1304348
## 502 0  1  0  0 0  0  0   1   1   0  0   0.6666667
## 503 0  3  0  0 0  0  0   0   0  26  0   0.1034483
## 7   0  3  0  0 0  1  0   1   0   2 13   0.3500000
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

RAN TWI ns7 30

mn="All_pRAN_TWI_NS7_pen30" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pRAN_TWI_NS7_pen30.shp", layer: "All_pRAN_TWI_NS7_pen30"
## with 216 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 216  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 19.44%
## Confusion matrix:
##     1 20 21 23  3 30 31 501 502 503  7 class.error
## 1   0  0  0  0  1  0  0   0   0   0  0  1.00000000
## 20  0 16  2  0  0  0  0   0   0   3  5  0.38461538
## 21  0  3  2  0  0  0  0   0   1   0  0  0.66666667
## 23  0  0  0 19  0  1  0   0   0   0  0  0.05000000
## 3   0  0  0  0 10  0  0   3   0   0  0  0.23076923
## 30  0  0  0  2  0  1  1   0   0   0  0  0.75000000
## 31  0  0  0  0  0  1  6   0   0   0  0  0.14285714
## 501 0  0  0  0  1  0  0  42   1   0  1  0.06666667
## 502 0  1  0  0  0  0  0   3   1   0  0  0.80000000
## 503 0  2  0  2  0  0  0   0   0  48  2  0.11111111
## 7   0  3  0  1  0  0  0   1   0   1 29  0.17142857
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

RAN TWI ns7 45

mn="All_pRAN_TWI_NS7_pen45" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pRAN_TWI_NS7_pen45.shp", layer: "All_pRAN_TWI_NS7_pen45"
## with 310 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 310  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 14.52%
## Confusion matrix:
##     1 20 21 23  3 30 31 501 502 503  7 class.error
## 1   2  0  0  0  0  0  0   0   0   0  0  0.00000000
## 20  0 22  2  0  0  0  0   0   1   5  4  0.35294118
## 21  0  3  5  0  0  0  0   0   0   0  0  0.37500000
## 23  0  0  0 21  0  2  1   0   0   3  0  0.22222222
## 3   0  0  0  0 17  0  0   2   0   0  0  0.10526316
## 30  0  0  0  3  0  2  0   0   0   0  0  0.60000000
## 31  0  0  0  0  0  0 11   0   0   0  0  0.00000000
## 501 0  0  0  0  2  0  0  64   0   0  1  0.04477612
## 502 0  1  0  0  0  0  0   2   4   0  0  0.42857143
## 503 0  3  1  2  0  0  0   0   0  71  2  0.10126582
## 7   0  1  0  1  0  0  0   0   0   3 46  0.09803922
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

LSF -ok

ns3

SNA LSF ns3 15

mn="All_pSNA_LSF_NS3_pen15" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pSNA_LSF_NS3_pen15.shp", layer: "All_pSNA_LSF_NS3_pen15"
## with 987 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 985  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 19.49%
## Confusion matrix:
##     1  20 21 23  3 30 31 501 502 503   7 class.error
## 1   2   0  0  0  4  0  0   0   0   0   0  0.66666667
## 20  0 114  7  0  0  0  0   1   2  14  17  0.26451613
## 21  0  20 36  0  0  0  0   0   1   1   0  0.37931034
## 23  0   0  0 75  0  3  5   0   0  17   0  0.25000000
## 3   0   0  0  0 51  0  0   1   0   0   0  0.01923077
## 30  0   0  0  8  0 20  2   0   0   0   2  0.37500000
## 31  0   0  0  3  0  0 38   0   0   0   0  0.07317073
## 501 0   1  0  0  9  0  0 142   1   0   5  0.10126582
## 502 0   2  0  0  0  0  0   1  14   2   2  0.33333333
## 503 0  12  0 13  0  0  0   0   2 196   4  0.13656388
## 7   0  16  0  1  0  1  0   6   0   6 105  0.22222222
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

SNA LSF ns3 30

mn="All_pSNA_LSF_NS3_pen30" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pSNA_LSF_NS3_pen30.shp", layer: "All_pSNA_LSF_NS3_pen30"
## with 1926 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 1924   10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 18.61%
## Confusion matrix:
##     1  20 21  23  3 30 31 501 502 503   7 class.error
## 1   6   0  0   0  6  0  0   0   0   0   0  0.50000000
## 20  0 209 17   0  0  0  0   7   2  37  31  0.31023102
## 21  0  37 65   0  0  0  0   1   2   3   0  0.39814815
## 23  0   0  0 150  0  6  6   0   0  27   2  0.21465969
## 3   3   0  0   0 88  0  0  12   0   0   0  0.14563107
## 30  0   0  0   7  0 49  2   0   0   0   3  0.19672131
## 31  0   0  0   4  0  0 76   0   0   1   0  0.06172840
## 501 0   2  0   0  8  0  0 298   0   0   6  0.05095541
## 502 0   6  1   0  0  0  0   2  25   1   4  0.35897436
## 503 0  25  1  15  0  0  0   0   2 391  12  0.12331839
## 7   0  29  0   0  0  3  0  16   1   8 209  0.21428571
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

SNA LSF ns3 45

mn="All_pSNA_LSF_NS3_pen45" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pSNA_LSF_NS3_pen45.shp", layer: "All_pSNA_LSF_NS3_pen45"
## with 2858 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 2856   10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 16.84%
## Confusion matrix:
##      1  20 21  23   3 30  31 501 502 503   7 class.error
## 1   10   0  0   0   7  0   0   0   0   0   0  0.41176471
## 20   0 331 30   0   0  0   0   4   4  43  35  0.25950783
## 21   0  52 98   0   0  0   0   2   2   4   0  0.37974684
## 23   0   0  0 231   0  9   5   0   0  35   2  0.18085106
## 3    2   0  0   0 133  0   0  18   0   0   0  0.13071895
## 30   0   0  0  14   0 66   3   0   0   0   6  0.25842697
## 31   0   0  0   7   0  4 109   0   0   1   0  0.09917355
## 501  0   2  0   0  13  0   0 444   0   0  12  0.05732484
## 502  0   4  0   0   0  0   0   2  45   2   4  0.21052632
## 503  0  40  2  25   0  1   0   0   2 585  11  0.12162162
## 7    0  32  1   0   0  3   0  20   1  15 323  0.18227848
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

RAN LSF ns3 15

mn="All_pRAN_LSF_NS3_pen15" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pRAN_LSF_NS3_pen15.shp", layer: "All_pRAN_LSF_NS3_pen15"
## with 987 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 985  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 29.04%
## Confusion matrix:
##     1 20 21 23  3 30 31 501 502 503  7 class.error
## 1   6  0  0  0  0  0  0   0   0   0  0  0.00000000
## 20  0 90 25  0  0  0  0   1   1  22 16  0.41935484
## 21  0 37 18  0  0  0  0   0   1   1  1  0.68965517
## 23  0  0  0 64  0  5  5   0   0  21  5  0.36000000
## 3   1  0  0  0 44  0  0   7   0   0  0  0.15384615
## 30  0  0  0  9  0 18  4   0   0   1  0  0.43750000
## 31  0  0  0  7  0  3 30   0   0   1  0  0.26829268
## 501 0  1  0  0  8  0  0 146   0   0  3  0.07594937
## 502 0  4  1  0  0  0  0   5   9   1  1  0.57142857
## 503 0 17  5 16  0  1  0   0   0 180  8  0.20704846
## 7   0 19  1  2  0  2  0   5   1  11 94  0.30370370
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

RAN LSF ns3 30

mn="All_pRAN_LSF_NS3_pen30" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pRAN_LSF_NS3_pen30.shp", layer: "All_pRAN_LSF_NS3_pen30"
## with 1926 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 1922   10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 23.26%
## Confusion matrix:
##      1  20 21  23  3 30 31 501 502 503   7 class.error
## 1   10   0  0   0  0  0  0   0   0   0   0  0.00000000
## 20   0 207 23   1  0  1  0   2   1  45  23  0.31683168
## 21   0  43 61   0  0  0  0   0   0   4   0  0.43518519
## 23   0   0  0 137  0 11  5   0   0  26  12  0.28272251
## 3    1   0  0   0 79  0  0  23   0   0   0  0.23300971
## 30   0   0  0  17  0 37  3   0   0   0   4  0.39344262
## 31   0   0  0  11  0  5 65   0   0   0   0  0.19753086
## 501  0   1  0   0 19  0  0 286   0   0   8  0.08917197
## 502  0   5  1   0  0  0  0   2  27   1   3  0.30769231
## 503  0  35  2  21  0  0  0   0   1 376  11  0.15695067
## 7    0  26  1   6  0  1  0  19   2  21 190  0.28571429
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

RAN LSF ns3 45

mn="All_pRAN_LSF_NS3_pen45" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pRAN_LSF_NS3_pen45.shp", layer: "All_pRAN_LSF_NS3_pen45"
## with 2858 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 2853   10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 20.15%
## Confusion matrix:
##      1  20 21  23   3 30 31 501 502 503   7 class.error
## 1   14   0  0   0   0  0  0   0   0   0   0  0.00000000
## 20   0 323 31   0   0  0  0   3   1  62  27  0.27740492
## 21   0  54 92   0   0  0  0   0   0  11   1  0.41772152
## 23   0   1  0 218   0 20 10   0   0  24   9  0.22695035
## 3    2   0  0   0 118  0  0  33   0   0   0  0.22875817
## 30   0   0  0  22   0 60  3   0   0   1   3  0.32584270
## 31   0   0  0  13   0  7 99   0   0   2   0  0.18181818
## 501  0   5  0   0  28  0  0 428   1   0   9  0.09129512
## 502  0   7  1   0   0  0  0   0  44   1   4  0.22807018
## 503  0  37  6  35   0  1  0   0   0 572  15  0.14114114
## 7    0  34  1   3   0  4  0  18   1  24 310  0.21518987
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

ns5

SNA LSF ns5 15

mn="All_pSNA_LSF_NS5_pen15" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pSNA_LSF_NS5_pen15.shp", layer: "All_pSNA_LSF_NS5_pen15"
## with 334 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 334  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 20.06%
## Confusion matrix:
##     1 20 21 23  3 30 31 501 502 503  7 class.error
## 1   1  0  0  0  1  0  0   0   0   0  0  0.50000000
## 20  0 26  3  0  0  0  0   2   0   7  6  0.40909091
## 21  0  6 13  0  0  0  0   0   0   1  1  0.38095238
## 23  0  0  0 22  0  2  0   0   0   5  0  0.24137931
## 3   0  0  0  0 19  0  0   0   0   0  0  0.00000000
## 30  0  0  0  2  0  6  1   0   0   0  0  0.33333333
## 31  0  0  0  0  0  1 11   0   0   0  0  0.08333333
## 501 0  2  0  0  0  0  0  56   0   0  2  0.06666667
## 502 0  2  0  0  0  0  0   0   4   0  1  0.42857143
## 503 0  3  0  1  0  0  0   0   0  72  3  0.08860759
## 7   0  9  0  0  0  1  0   2   0   3 37  0.28846154
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

SNA LSF ns5 30

mn="All_pSNA_LSF_NS5_pen30" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pSNA_LSF_NS5_pen30.shp", layer: "All_pSNA_LSF_NS5_pen30"
## with 629 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 629  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 18.12%
## Confusion matrix:
##     1 20 21 23  3 30 31 501 502 503  7 class.error
## 1   1  0  0  0  3  0  0   0   0   0  0  0.75000000
## 20  0 47  7  0  0  0  0   4   0   9 14  0.41975309
## 21  0 11 18  0  0  0  0   1   1   1  0  0.43750000
## 23  0  0  0 41  0  4  1   0   0   7  1  0.24074074
## 3   0  0  0  0 36  0  0   1   0   0  0  0.02702703
## 30  0  0  0  3  0 11  1   0   0   0  0  0.26666667
## 31  0  0  0  0  0  2 22   0   0   0  0  0.08333333
## 501 0  2  0  0  3  0  0 114   0   0  1  0.05000000
## 502 0  4  0  0  0  0  0   0  10   0  0  0.28571429
## 503 0  9  0  4  0  0  0   0   0 137  2  0.09868421
## 7   0 11  0  0  0  1  0   1   0   5 78  0.18750000
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

SNA LSF ns5 45

mn="All_pSNA_LSF_NS5_pen45" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pSNA_LSF_NS5_pen45.shp", layer: "All_pSNA_LSF_NS5_pen45"
## with 927 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 927  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 16.07%
## Confusion matrix:
##     1 20 21 23  3 30 31 501 502 503   7 class.error
## 1   1  0  0  0  4  0  0   0   0   0   0  0.80000000
## 20  0 73  9  0  0  0  0   5   0  15  16  0.38135593
## 21  0 14 27  0  0  0  0   1   0   1   1  0.38636364
## 23  0  0  0 68  0  4  2   0   0   7   0  0.16049383
## 3   1  0  0  0 53  0  0   1   0   0   0  0.03636364
## 30  0  0  0  4  0 17  0   0   0   0   1  0.22727273
## 31  0  0  0  0  0  0 36   0   0   0   0  0.00000000
## 501 0  1  0  0  5  0  0 168   0   0   4  0.05617978
## 502 0  5  0  0  0  0  0   0  15   0   1  0.28571429
## 503 0 12  0  5  0  0  0   0   1 202   6  0.10619469
## 7   0 12  0  0  0  1  0   3   0   7 118  0.16312057
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

RAN LSF ns5 15

mn="All_pRAN_LSF_NS5_pen15" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pRAN_LSF_NS5_pen15.shp", layer: "All_pRAN_LSF_NS5_pen15"
## with 334 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 334  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 25.45%
## Confusion matrix:
##     1 20 21 23  3 30 31 501 502 503  7 class.error
## 1   1  0  0  0  1  0  0   0   0   0  0   0.5000000
## 20  0 25  5  0  0  0  0   0   0   6  8   0.4318182
## 21  0  8 12  0  0  0  0   0   0   1  0   0.4285714
## 23  0  0  0 19  0  3  1   0   0   4  2   0.3448276
## 3   1  0  0  0 15  0  0   3   0   0  0   0.2105263
## 30  0  0  0  6  0  2  1   0   0   0  0   0.7777778
## 31  0  0  0  2  0  1  9   0   0   0  0   0.2500000
## 501 0  0  0  0  4  0  0  54   1   0  1   0.1000000
## 502 0  1  1  0  0  0  0   2   2   0  1   0.7142857
## 503 0  5  1  3  0  0  0   0   0  70  0   0.1139241
## 7   0  6  0  2  0  0  0   1   0   3 40   0.2307692
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

RAN LSF ns5 30

mn="All_pRAN_LSF_NS5_pen30" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pRAN_LSF_NS5_pen30.shp", layer: "All_pRAN_LSF_NS5_pen30"
## with 629 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 629  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 21.14%
## Confusion matrix:
##     1 20 21 23  3 30 31 501 502 503  7 class.error
## 1   2  0  0  0  2  0  0   0   0   0  0   0.5000000
## 20  0 56  6  0  0  0  0   0   0   8 11   0.3086420
## 21  0 14 17  0  0  0  0   0   0   1  0   0.4687500
## 23  0  0  0 36  0  4  3   0   0   9  2   0.3333333
## 3   0  0  0  0 29  0  0   8   0   0  0   0.2162162
## 30  0  0  0  5  0  7  2   0   0   0  1   0.5333333
## 31  0  0  0  4  0  0 20   0   0   0  0   0.1666667
## 501 0  1  0  0 10  0  0 108   1   0  0   0.1000000
## 502 0  3  0  0  0  0  0   1  10   0  0   0.2857143
## 503 0  4  3  6  0  0  0   0   0 134  5   0.1184211
## 7   0  9  0  2  0  0  0   2   0   6 77   0.1979167
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

RAN LSF ns5 45

mn="All_pRAN_LSF_NS5_pen45" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pRAN_LSF_NS5_pen45.shp", layer: "All_pRAN_LSF_NS5_pen45"
## with 927 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 927  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 17.91%
## Confusion matrix:
##     1 20 21 23  3 30 31 501 502 503   7 class.error
## 1   4  0  0  0  1  0  0   0   0   0   0  0.20000000
## 20  0 77  8  0  0  0  0   1   0  14  18  0.34745763
## 21  0 16 27  0  0  0  0   0   0   1   0  0.38636364
## 23  0  0  0 58  0  7  2   0   0  12   2  0.28395062
## 3   0  0  0  0 43  0  0  12   0   0   0  0.21818182
## 30  0  0  0  5  0 15  0   0   0   0   2  0.31818182
## 31  0  0  0  4  0  1 30   0   0   0   1  0.16666667
## 501 0  2  0  0  6  0  0 168   0   0   2  0.05617978
## 502 0  1  0  0  0  0  0   3  15   0   2  0.28571429
## 503 0  8  1  7  0  0  0   0   0 204   6  0.09734513
## 7   0 11  0  1  0  1  0   0   0   8 120  0.14893617
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

ns7

SNA LSF ns7 15

mn="All_pSNA_LSF_NS7_pen15" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pSNA_LSF_NS7_pen15.shp", layer: "All_pSNA_LSF_NS7_pen15"
## with 121 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 121  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 28.93%
## Confusion matrix:
##     1 20 21 23 3 30 31 501 502 503  7 class.error
## 1   0  0  0  0 1  0  0   0   0   0  0  1.00000000
## 20  0 11  2  0 0  0  0   0   0   2  3  0.38888889
## 21  0  2  2  0 0  0  0   0   0   0  0  0.50000000
## 23  0  0  0  7 0  1  0   0   0   3  0  0.36363636
## 3   0  0  0  0 6  0  0   1   0   0  0  0.14285714
## 30  0  0  0  2 0  0  0   0   0   0  0  1.00000000
## 31  0  0  0  0 0  0  4   0   0   0  0  0.00000000
## 501 0  0  0  0 0  0  0  22   0   0  1  0.04347826
## 502 0  1  0  0 1  0  0   0   0   0  1  1.00000000
## 503 0  1  0  3 0  0  0   0   0  24  0  0.14285714
## 7   0  7  0  0 0  0  0   1   0   2 10  0.50000000
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

SNA LSF ns7 30

mn="All_pSNA_LSF_NS7_pen30" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pSNA_LSF_NS7_pen30.shp", layer: "All_pSNA_LSF_NS7_pen30"
## with 217 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 217  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 17.97%
## Confusion matrix:
##     1 20 21 23  3 30 31 501 502 503  7 class.error
## 1   0  0  0  0  2  0  0   0   0   0  0  1.00000000
## 20  0 17  0  0  0  0  0   0   0   6  5  0.39285714
## 21  0  3  2  0  0  0  0   0   0   0  0  0.60000000
## 23  0  0  0 15  0  1  0   0   0   3  0  0.21052632
## 3   0  0  0  0 14  0  0   0   0   0  0  0.00000000
## 30  0  0  0  1  0  2  0   0   0   0  0  0.33333333
## 31  0  0  0  0  0  0  7   0   0   0  0  0.00000000
## 501 0  0  0  0  0  0  0  45   0   0  1  0.02173913
## 502 0  1  0  0  1  0  0   1   2   0  0  0.60000000
## 503 0  2  0  2  0  0  0   0   0  48  1  0.09433962
## 7   0  6  0  0  0  0  0   1   0   2 26  0.25714286
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

SNA LSF ns7 45

mn="All_pSNA_LSF_NS7_pen45" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pSNA_LSF_NS7_pen45.shp", layer: "All_pSNA_LSF_NS7_pen45"
## with 309 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 309  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 18.77%
## Confusion matrix:
##     1 20 21 23  3 30 31 501 502 503  7 class.error
## 1   0  0  0  0  2  0  0   0   0   0  0  1.00000000
## 20  0 21  2  0  0  0  0   0   1   6  6  0.41666667
## 21  0  2  6  0  0  0  0   0   0   0  0  0.25000000
## 23  0  0  0 19  0  0  0   0   0   8  0  0.29629630
## 3   0  0  0  0 20  0  0   0   0   0  0  0.00000000
## 30  0  0  0  1  0  3  0   0   0   0  0  0.25000000
## 31  0  0  0  1  0  0 10   0   0   0  0  0.09090909
## 501 0  0  0  0  0  0  0  65   1   0  2  0.04411765
## 502 0  0  0  0  0  0  0   2   4   0  1  0.42857143
## 503 0  3  0  5  0  0  0   0   0  66  3  0.14285714
## 7   0  7  0  0  0  0  0   1   0   4 37  0.24489796
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

RAN LSF ns7 15

mn="All_pRAN_LSF_NS7_pen15" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pRAN_LSF_NS7_pen15.shp", layer: "All_pRAN_LSF_NS7_pen15"
## with 121 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 121  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 30.58%
## Confusion matrix:
##     1 20 21 23 3 30 31 501 502 503  7 class.error
## 1   0  0  0  0 1  0  0   0   0   0  0  1.00000000
## 20  0 12  1  0 0  0  0   0   0   2  3  0.33333333
## 21  0  3  0  0 0  0  0   0   1   0  0  1.00000000
## 23  0  0  0  5 0  2  1   0   0   3  0  0.54545455
## 3   0  0  0  0 5  0  0   2   0   0  0  0.28571429
## 30  0  0  0  1 0  0  0   0   0   1  0  1.00000000
## 31  0  0  0  3 0  0  1   0   0   0  0  0.75000000
## 501 0  0  0  0 1  0  0  21   1   0  0  0.08695652
## 502 0  1  1  0 1  0  0   0   0   0  0  1.00000000
## 503 0  2  0  2 0  0  0   0   0  23  1  0.17857143
## 7   0  1  0  0 0  0  0   0   0   2 17  0.15000000
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

RAN LSF ns7 30

mn="All_pRAN_LSF_NS7_pen30" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pRAN_LSF_NS7_pen30.shp", layer: "All_pRAN_LSF_NS7_pen30"
## with 217 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 217  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 18.89%
## Confusion matrix:
##     1 20 21 23  3 30 31 501 502 503  7 class.error
## 1   1  0  0  0  1  0  0   0   0   0  0  0.50000000
## 20  0 19  0  0  0  0  0   0   1   4  4  0.32142857
## 21  0  3  1  0  0  0  0   0   1   0  0  0.80000000
## 23  0  0  0 13  0  2  1   0   0   3  0  0.31578947
## 3   1  0  0  0 12  0  0   1   0   0  0  0.14285714
## 30  0  0  0  2  0  0  0   0   0   1  0  1.00000000
## 31  0  0  0  1  0  0  6   0   0   0  0  0.14285714
## 501 0  0  0  0  0  0  0  44   1   0  1  0.04347826
## 502 0  2  0  0  1  0  0   0   1   0  1  0.80000000
## 503 0  3  0  3  0  0  0   0   0  47  0  0.11320755
## 7   0  1  0  0  0  0  0   1   0   1 32  0.08571429
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

RAN LSF ns7 45

mn="All_pRAN_LSF_NS7_pen45" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pRAN_LSF_NS7_pen45.shp", layer: "All_pRAN_LSF_NS7_pen45"
## with 309 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 309  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 15.53%
## Confusion matrix:
##     1 20 21 23  3 30 31 501 502 503  7 class.error
## 1   1  0  0  0  1  0  0   0   0   0  0  0.50000000
## 20  0 28  1  0  0  0  0   0   0   4  3  0.22222222
## 21  0  2  4  0  0  0  0   0   2   0  0  0.50000000
## 23  0  0  0 18  0  3  0   0   0   6  0  0.33333333
## 3   0  0  0  0 18  0  0   2   0   0  0  0.10000000
## 30  0  0  0  4  0  0  0   0   0   0  0  1.00000000
## 31  0  0  0  2  0  0  9   0   0   0  0  0.18181818
## 501 0  0  0  0  3  0  0  64   0   0  1  0.05882353
## 502 0  0  0  0  0  0  0   2   4   0  1  0.42857143
## 503 0  4  0  1  0  0  0   0   0  70  2  0.09090909
## 7   0  2  0  0  0  0  0   1   0   1 45  0.08163265
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

VD -ok

ns3

SNA VD ns3 15

mn="All_pSNA_VD_NS3_pen15" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pSNA_VD_NS3_pen15.shp", layer: "All_pSNA_VD_NS3_pen15"
## with 1042 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 1040   10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 16.83%
## Confusion matrix:
##     1  20 21 23  3 30 31 501 502 503   7 class.error
## 1   3   0  0  0  3  0  0   0   0   0   0  0.50000000
## 20  0 125  7  0  0  0  0   1   0  19  10  0.22839506
## 21  0  22 34  0  0  0  0   1   0   3   0  0.43333333
## 23  0   0  0 78  0  7  0   0   0  11   6  0.23529412
## 3   1   0  0  0 45  0  0   9   0   0   0  0.18181818
## 30  0   0  0  8  0 25  0   0   0   0   0  0.24242424
## 31  0   0  0  6  0  1 36   0   0   0   0  0.16279070
## 501 0   0  0  0  8  0  0 161   0   0   1  0.05294118
## 502 0   4  0  0  0  0  0   3  13   0   2  0.40909091
## 503 0  13  0  6  0  0  0   0   0 215   9  0.11522634
## 7   0   8  0  0  0  0  0   2   0   4 130  0.09722222
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

SNA VD ns3 30

mn="All_pSNA_VD_NS3_pen30" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pSNA_VD_NS3_pen30.shp", layer: "All_pSNA_VD_NS3_pen30"
## with 2045 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 2043   10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 15.96%
## Confusion matrix:
##     1  20 21  23  3 30 31 501 502 503   7 class.error
## 1   9   0  0   0  3  0  0   0   0   0   0   0.2500000
## 20  0 242 15   0  0  0  0   0   1  38  22   0.2389937
## 21  0  33 73   0  0  0  0   0   1   4   1   0.3482143
## 23  0   0  0 155  0 10  2   0   0  18  10   0.2051282
## 3   3   0  0   0 94  0  0  13   0   0   0   0.1454545
## 30  0   0  0  12  0 47  1   0   0   1   1   0.2419355
## 31  0   0  0  10  0  2 73   0   0   0   0   0.1411765
## 501 0   0  0   0 13  0  0 323   1   1   2   0.0500000
## 502 0   5  2   0  0  0  0   6  27   0   2   0.3571429
## 503 0  26  0  11  0  1  0   1   0 432  13   0.1074380
## 7   0  19  0   2  0  0  0   5   1  14 242   0.1448763
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

SNA VD ns3 45

mn="All_pSNA_VD_NS3_pen45" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pSNA_VD_NS3_pen45.shp", layer: "All_pSNA_VD_NS3_pen45"
## with 3041 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 3035   10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 15.62%
## Confusion matrix:
##      1  20  21  23   3 30  31 501 502 503   7 class.error
## 1   12   0   0   0   3  0   0   0   0   0   0  0.20000000
## 20   0 357  24   0   0  0   0   3   0  55  31  0.24042553
## 21   0  56 104   0   0  0   0   0   0   5   1  0.37349398
## 23   0   0   0 229   0 18   8   0   0  21  13  0.20761246
## 3    3   0   0   0 140  0   0  22   0   0   0  0.15151515
## 30   0   0   0  18   0 66   2   0   0   1   3  0.26666667
## 31   0   0   0  12   0  3 112   0   0   0   0  0.11811024
## 501  0   1   0   0  17  0   0 489   1   0   2  0.04117647
## 502  0   4   2   0   0  0   0   7  45   0   3  0.26229508
## 503  0  42   0  17   0  1   0   2   0 646  15  0.10650069
## 7    0  27   0   3   0  2   0   7   1  18 361  0.13842482
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

RAN VD ns3 15

mn="All_pRAN_VD_NS3_pen15" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pRAN_VD_NS3_pen15.shp", layer: "All_pRAN_VD_NS3_pen15"
## with 1042 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 1039   10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 25.79%
## Confusion matrix:
##     1  20 21 23  3 30 31 501 502 503   7 class.error
## 1   3   0  0  0  2  0  0   0   0   0   0  0.40000000
## 20  0 107 12  0  0  0  0   0   3  25  15  0.33950617
## 21  0  31 27  0  0  0  0   1   0   1   0  0.55000000
## 23  0   0  0 70  0  7  3   0   0  18   4  0.31372549
## 3   3   0  0  0 39  0  0  13   0   0   0  0.29090909
## 30  0   0  0  9  0 14  5   0   0   2   3  0.57575758
## 31  0   0  0  8  0  5 30   0   0   0   0  0.30232558
## 501 0   0  0  0  8  0  0 158   0   0   4  0.07058824
## 502 0   2  1  0  0  0  0   6  10   0   3  0.54545455
## 503 0  28  1  9  0  2  0   0   0 198   5  0.18518519
## 7   0  17  0  1  0  3  0   3   1   4 115  0.20138889
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

RAN VD ns3 30

mn="All_pRAN_VD_NS3_pen30" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pRAN_VD_NS3_pen30.shp", layer: "All_pRAN_VD_NS3_pen30"
## with 2045 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 2042   10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 21.25%
## Confusion matrix:
##      1  20 21  23  3 30 31 501 502 503   7 class.error
## 1   10   0  0   0  1  0  0   0   0   0   0  0.09090909
## 20   0 211 31   0  0  0  0   6   2  50  18  0.33647799
## 21   0  44 63   0  0  0  0   1   1   3   0  0.43750000
## 23   0   0  0 146  0 11  4   0   0  24  10  0.25128205
## 3    0   0  0   0 88  0  0  22   0   0   0  0.20000000
## 30   0   0  0  16  0 38  5   0   0   1   2  0.38709677
## 31   0   0  0  12  0  4 69   0   0   0   0  0.18823529
## 501  0   1  1   0 19  0  0 310   0   0   9  0.08823529
## 502  0   6  0   0  0  0  0   3  31   0   2  0.26190476
## 503  0  37  3  13  0  0  0   0   0 417  14  0.13842975
## 7    0  25  0   4  0  2  0  11   3  13 225  0.20494700
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

RAN VD ns3 45

mn="All_pRAN_VD_NS3_pen45" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pRAN_VD_NS3_pen45.shp", layer: "All_pRAN_VD_NS3_pen45"
## with 3041 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 3037   10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 19%
## Confusion matrix:
##      1  20 21  23   3 30  31 501 502 503   7 class.error
## 1   15   0  0   0   2  0   0   0   0   0   0  0.11764706
## 20   0 334 31   0   0  0   0   3   5  65  32  0.28936170
## 21   0  60 94   0   0  0   0   0   3   9   0  0.43373494
## 23   0   0  0 213   0 15   6   0   0  41  14  0.26297578
## 3    3   0  0   0 128  0   0  34   0   0   0  0.22424242
## 30   0   0  0  17   0 65   3   0   0   1   4  0.27777778
## 31   0   0  0  14   0  3 110   0   0   0   0  0.13385827
## 501  0   2  0   0  31  0   0 466   1   0  10  0.08627451
## 502  0   7  0   0   0  0   0   2  49   0   3  0.19672131
## 503  0  39  6  26   0  1   0   0   0 635  16  0.12171508
## 7    0  27  0   4   0  4   0  14   2  17 351  0.16229117
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

ns5

SNA VD ns5 15

mn="All_pSNA_VD_NS5_pen15" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pSNA_VD_NS5_pen15.shp", layer: "All_pSNA_VD_NS5_pen15"
## with 355 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 355  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 21.69%
## Confusion matrix:
##     1 20 21 23  3 30 31 501 502 503  7 class.error
## 1   1  0  0  0  1  0  0   0   0   0  0  0.50000000
## 20  0 33  3  0  0  0  0   0   0   5  7  0.31250000
## 21  0  8 10  0  0  0  0   1   0   2  0  0.52380952
## 23  0  0  0 22  0  1  0   0   0   3  4  0.26666667
## 3   1  0  0  0 16  0  0   3   0   0  0  0.20000000
## 30  0  0  0  7  0  0  0   0   0   0  1  1.00000000
## 31  0  0  0  1  0  0 12   0   0   0  0  0.07692308
## 501 0  0  0  0  2  0  0  61   0   0  2  0.06153846
## 502 0  3  0  0  0  0  0   3   1   0  1  0.87500000
## 503 0  2  1  1  0  0  0   0   0  80  3  0.08045977
## 7   0  4  0  0  0  0  0   2   0   5 42  0.20754717
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

SNA VD ns5 30

mn="All_pSNA_VD_NS5_pen30" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pSNA_VD_NS5_pen30.shp", layer: "All_pSNA_VD_NS5_pen30"
## with 675 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 674  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 17.36%
## Confusion matrix:
##     1 20 21 23  3 30 31 501 502 503  7 class.error
## 1   2  0  0  0  1  0  0   0   0   0  0  0.33333333
## 20  0 65  5  0  0  0  0   1   0  11  6  0.26136364
## 21  0 11 20  0  0  0  0   0   0   1  0  0.37500000
## 23  0  0  0 44  0  5  1   0   0   2  3  0.20000000
## 3   1  0  0  0 35  0  0   3   0   0  0  0.10256410
## 30  0  0  0 12  0  2  0   0   0   0  1  0.86666667
## 31  0  0  0  1  0  0 25   0   0   0  0  0.03846154
## 501 0  0  0  0  5  0  0 123   1   0  1  0.05384615
## 502 0  3  0  0  0  0  0   3   7   0  2  0.53333333
## 503 0  9  0  2  0  0  0   0   0 152  5  0.09523810
## 7   0  8  0  1  0  0  0   2   0  10 82  0.20388350
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

SNA VD ns5 45

mn="All_pSNA_VD_NS5_pen45" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pSNA_VD_NS5_pen45.shp", layer: "All_pSNA_VD_NS5_pen45"
## with 993 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 992  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 15.32%
## Confusion matrix:
##     1  20 21 23  3 30 31 501 502 503   7 class.error
## 1   3   0  0  0  1  0  0   0   0   0   0  0.25000000
## 20  0 104  3  0  0  0  0   0   1  15   8  0.20610687
## 21  0  18 25  0  0  0  0   0   0   1   0  0.43181818
## 23  0   0  0 67  0  5  2   0   0   4   3  0.17283951
## 3   0   0  0  0 54  0  0   4   0   0   0  0.06896552
## 30  0   0  0 13  0  6  0   0   0   0   1  0.70000000
## 31  0   0  0  1  0  0 38   0   0   0   0  0.02564103
## 501 0   1  0  0  6  0  0 186   0   0   1  0.04123711
## 502 0   5  0  0  0  0  0   4  12   0   1  0.45454545
## 503 0  15  0  3  0  0  0   0   0 224   8  0.10400000
## 7   0  11  0  1  0  0  0   2   0  14 121  0.18791946
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

RAN VD ns5 15

mn="All_pRAN_VD_NS5_pen15" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pRAN_VD_NS5_pen15.shp", layer: "All_pRAN_VD_NS5_pen15"
## with 355 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 355  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 32.68%
## Confusion matrix:
##     1 20 21 23  3 30 31 501 502 503  7 class.error
## 1   1  0  0  0  1  0  0   0   0   0  0   0.5000000
## 20  0 22  8  0  0  0  0   0   0  10  8   0.5416667
## 21  0 13  6  0  0  0  0   0   0   1  1   0.7142857
## 23  0  0  0 17  0  3  4   0   0   5  1   0.4333333
## 3   0  0  0  0 12  0  0   8   0   0  0   0.4000000
## 30  0  0  0  7  0  1  0   0   0   0  0   0.8750000
## 31  0  0  0  5  0  0  8   0   0   0  0   0.3846154
## 501 0  0  0  0  7  0  0  57   0   0  1   0.1230769
## 502 0  1  0  0  0  0  0   3   1   0  3   0.8750000
## 503 0  7  0  3  0  0  0   0   0  74  3   0.1494253
## 7   0  7  0  1  0  0  0   2   0   3 40   0.2452830
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

RAN VD ns5 30

mn="All_pRAN_VD_NS5_pen30" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pRAN_VD_NS5_pen30.shp", layer: "All_pRAN_VD_NS5_pen30"
## with 675 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 675  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 24.15%
## Confusion matrix:
##     1 20 21 23  3 30 31 501 502 503  7 class.error
## 1   1  0  0  0  3  0  0   0   0   0  0  0.75000000
## 20  0 57 10  0  0  0  0   0   0  12  9  0.35227273
## 21  0 14 17  0  0  0  0   0   0   1  0  0.46875000
## 23  0  0  0 34  0  5  2   0   0  11  3  0.38181818
## 3   1  0  0  0 29  0  0   9   0   0  0  0.25641026
## 30  0  0  0  7  0  5  3   0   0   0  0  0.66666667
## 31  0  0  0  4  0  2 20   0   0   0  0  0.23076923
## 501 0  0  0  0  8  0  0 120   1   0  1  0.07692308
## 502 0  3  1  0  0  0  0   2   8   0  1  0.46666667
## 503 0  9  2 10  0  0  0   0   0 145  2  0.13690476
## 7   0 13  0  2  0  0  0   4   1   7 76  0.26213592
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

RAN VD ns5 45

mn="All_pRAN_VD_NS5_pen45" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pRAN_VD_NS5_pen45.shp", layer: "All_pRAN_VD_NS5_pen45"
## with 993 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 992  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 17.04%
## Confusion matrix:
##     1 20 21 23  3 30 31 501 502 503   7 class.error
## 1   3  0  0  0  1  0  0   0   0   0   0  0.25000000
## 20  0 93  9  0  0  0  0   1   0  15  13  0.29007634
## 21  0 15 27  0  0  0  0   0   0   2   0  0.38636364
## 23  0  0  0 65  0  3  3   0   0   9   1  0.19753086
## 3   0  0  0  0 44  0  0  14   0   0   0  0.24137931
## 30  0  0  0  9  0  8  3   0   0   0   0  0.60000000
## 31  0  0  0  3  0  1 33   0   0   0   2  0.15384615
## 501 0  0  0  0  7  0  0 185   0   0   2  0.04639175
## 502 0  1  0  0  0  0  0   3  17   0   1  0.22727273
## 503 0 10  1  7  0  0  0   0   0 229   3  0.08400000
## 7   0 14  0  1  0  0  1   3   1  10 119  0.20134228
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

ns7

SNA VD ns7 15

mn="All_pSNA_VD_NS7_pen15" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pSNA_VD_NS7_pen15.shp", layer: "All_pSNA_VD_NS7_pen15"
## with 257 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 256  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 13.28%
## Confusion matrix:
##     1 20 21 23  3 30 31 501 502 503  7 class.error
## 1   0  0  0  0  1  0  0   0   0   0  0  1.00000000
## 20  0 29  2  0  0  0  0   0   0   4  0  0.17142857
## 21  0  2  6  0  0  0  0   0   0   0  0  0.25000000
## 23  0  0  0 22  0  0  0   0   0   0  0  0.00000000
## 3   0  0  0  0 12  0  0   2   0   0  0  0.14285714
## 30  0  0  0  2  0  2  0   0   0   0  0  0.50000000
## 31  0  0  0  3  0  0  5   0   0   0  0  0.37500000
## 501 0  0  0  0  0  0  0  51   0   0  1  0.01923077
## 502 0  2  0  0  0  0  0   4   0   0  1  1.00000000
## 503 0  2  0  0  0  0  0   0   0  57  3  0.08064516
## 7   0  3  0  0  0  0  0   0   0   2 38  0.11627907
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

SNA VD ns7 30

mn="All_pSNA_VD_NS7_pen30" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pSNA_VD_NS7_pen30.shp", layer: "All_pSNA_VD_NS7_pen30"
## with 227 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 226  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 19.47%
## Confusion matrix:
##     20 21 23  3 30 31 501 502 503  7 class.error
## 20  16  0  0  0  0  0   0   0   5  6   0.4074074
## 21   3  2  0  0  0  0   0   0   0  0   0.6000000
## 23   0  0 15  0  1  1   0   0   1  1   0.2105263
## 3    0  0  0 13  0  0   0   0   0  0   0.0000000
## 30   0  0  1  0  0  1   0   0   0  1   1.0000000
## 31   0  0  2  0  0  5   0   0   0  0   0.2857143
## 501  0  0  0  0  0  0  51   0   0  0   0.0000000
## 502  2  0  0  0  0  0   3   0   0  1   1.0000000
## 503  2  0  0  0  0  0   0   0  52  3   0.0877193
## 7    2  0  1  0  0  0   1   0   6 28   0.2631579
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

SNA VD ns7 45

mn="All_pSNA_VD_NS7_pen45" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pSNA_VD_NS7_pen45.shp", layer: "All_pSNA_VD_NS7_pen45"
## with 323 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 322  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 18.63%
## Confusion matrix:
##     20 21 23  3 30 31 501 502 503  7 class.error
## 20  23  1  0  0  0  0   0   0   6  5  0.34285714
## 21   4  4  0  0  0  0   0   0   0  0  0.50000000
## 23   0  0 21  0  2  2   0   0   1  2  0.25000000
## 3    0  0  0 18  0  0   2   0   0  0  0.10000000
## 30   0  0  3  0  0  0   0   0   0  1  1.00000000
## 31   0  0  2  0  0  8   0   0   0  0  0.20000000
## 501  0  0  0  1  0  0  73   0   0  1  0.02666667
## 502  2  0  0  0  0  0   4   0   0  1  1.00000000
## 503  4  0  1  0  0  0   0   0  72  4  0.11111111
## 7    2  0  1  0  0  0   1   0   7 43  0.20370370
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

RAN VD ns7 15

mn="All_pRAN_VD_NS7_pen15" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pRAN_VD_NS7_pen15.shp", layer: "All_pRAN_VD_NS7_pen15"
## with 129 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 129  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 24.03%
## Confusion matrix:
##     1 20 21 23 3 30 31 501 502 503  7 class.error
## 1   0  0  0  0 1  0  0   0   0   0  0  1.00000000
## 20  0 10  1  0 0  0  0   0   0   1  5  0.41176471
## 21  0  4  0  0 0  0  0   0   0   0  0  1.00000000
## 23  0  0  0  8 0  1  0   0   0   2  0  0.27272727
## 3   0  0  0  0 7  0  0   0   0   0  0  0.00000000
## 30  0  0  0  2 0  0  0   0   0   0  0  1.00000000
## 31  0  0  0  0 0  0  4   0   0   0  0  0.00000000
## 501 0  0  0  0 0  0  0  25   1   0  0  0.03846154
## 502 0  2  0  0 0  0  0   1   0   0  1  1.00000000
## 503 0  1  0  2 0  0  0   0   0  26  2  0.16129032
## 7   0  2  0  0 0  0  0   1   0   1 18  0.18181818
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

RAN VD ns7 30

mn="All_pRAN_VD_NS7_pen30" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pRAN_VD_NS7_pen30.shp", layer: "All_pRAN_VD_NS7_pen30"
## with 227 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 227  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 22.47%
## Confusion matrix:
##     1 20 21 23  3 30 31 501 502 503  7 class.error
## 1   0  0  0  0  1  0  0   0   0   0  0  1.00000000
## 20  0 17  0  0  0  0  0   0   0   5  5  0.37037037
## 21  0  3  2  0  0  0  0   0   0   0  0  0.60000000
## 23  0  0  0 12  0  3  0   0   0   4  0  0.36842105
## 3   1  0  0  0 11  0  0   1   0   0  0  0.15384615
## 30  0  0  0  3  0  0  0   0   0   0  0  1.00000000
## 31  0  0  0  2  0  0  5   0   0   0  0  0.28571429
## 501 0  0  0  0  1  0  0  48   0   0  2  0.05882353
## 502 0  1  0  0  0  0  0   2   3   0  0  0.50000000
## 503 0  4  0  3  0  0  0   0   0  48  2  0.15789474
## 7   0  2  0  1  0  0  0   1   0   4 30  0.21052632
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

RAN VD ns7 45

mn="All_pRAN_VD_NS7_pen45" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pRAN_VD_NS7_pen45.shp", layer: "All_pRAN_VD_NS7_pen45"
## with 323 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 323  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 16.72%
## Confusion matrix:
##     1 20 21 23  3 30 31 501 502 503  7 class.error
## 1   0  0  0  0  1  0  0   0   0   0  0  1.00000000
## 20  0 26  1  0  0  0  0   0   1   2  5  0.25714286
## 21  0  4  4  0  0  0  0   0   0   0  0  0.50000000
## 23  0  0  0 19  0  2  0   0   0   6  1  0.32142857
## 3   0  0  0  0 18  0  0   2   0   0  0  0.10000000
## 30  0  0  0  4  0  0  0   0   0   0  0  1.00000000
## 31  0  0  0  2  0  0  8   0   0   0  0  0.20000000
## 501 0  0  0  0  3  0  0  71   0   0  1  0.05333333
## 502 0  4  0  0  0  0  0   3   0   0  0  1.00000000
## 503 0  0  0  3  0  0  0   0   0  78  0  0.03703704
## 7   0  3  0  1  0  0  0   1   0   4 45  0.16666667
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

RSP -ok

ns3

SNA RSP ns3 15

mn="All_pSNA_RSP_NS3_pen15" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pSNA_RSP_NS3_pen15.shp", layer: "All_pSNA_RSP_NS3_pen15"
## with 1045 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 1043   10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 18.31%
## Confusion matrix:
##     1  20 21 23  3 30 31 501 502 503   7 class.error
## 1   3   0  0  0  3  0  0   0   0   0   0  0.50000000
## 20  0 125  7  0  0  0  0   1   0  23   9  0.24242424
## 21  0  25 35  0  0  0  0   0   0   2   0  0.43548387
## 23  0   0  0 83  0  5  0   0   0  12   2  0.18627451
## 3   1   0  0  0 44  0  0  10   0   0   0  0.20000000
## 30  0   0  0 11  0 22  0   0   0   0   0  0.33333333
## 31  0   0  0  2  0  3 35   0   0   0   0  0.12500000
## 501 0   0  0  0  8  0  0 159   1   0   2  0.06470588
## 502 0   0  1  0  0  0  0   3  16   1   1  0.27272727
## 503 0  16  0  4  0  0  0   0   0 211  13  0.13524590
## 7   0  10  0  1  0  0  0   3   0  11 119  0.17361111
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

SNA RSP ns3 30

mn="All_pSNA_RSP_NS3_pen30" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pSNA_RSP_NS3_pen30.shp", layer: "All_pSNA_RSP_NS3_pen30"
## with 2037 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 2035   10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 15.04%
## Confusion matrix:
##     1  20 21  23  3 30 31 501 502 503   7 class.error
## 1   8   0  0   0  4  0  0   0   0   0   0  0.33333333
## 20  0 246 13   0  0  0  0   2   0  41  16  0.22641509
## 21  0  33 76   0  0  0  0   0   1   4   0  0.33333333
## 23  0   0  0 170  0  8  0   0   0  12   5  0.12820513
## 3   3   0  0   0 96  0  0  11   0   0   0  0.12727273
## 30  0   0  0  16  0 45  0   0   0   1   0  0.27419355
## 31  0   0  0   4  0  2 74   0   0   0   0  0.07500000
## 501 0   0  0   0 12  0  0 320   2   0   6  0.05882353
## 502 0   5  2   0  0  0  0   4  27   0   3  0.34146341
## 503 0  26  0  11  0  0  0   1   0 427  17  0.11410788
## 7   0  20  0   2  0  0  0   6   1  12 240  0.14590747
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

SNA RSP ns3 45

mn="All_pSNA_RSP_NS3_pen45" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pSNA_RSP_NS3_pen45.shp", layer: "All_pSNA_RSP_NS3_pen45"
## with 3037 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 3032   10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 15.11%
## Confusion matrix:
##      1  20  21  23   3 30  31 501 502 503   7 class.error
## 1   12   0   0   0   3  0   0   0   0   0   0  0.20000000
## 20   0 370  19   0   0  0   0   1   1  49  31  0.21443737
## 21   0  59 104   0   0  0   0   0   0   7   0  0.38823529
## 23   0   0   0 234   0 16   2   0   0  24  12  0.18750000
## 3    3   0   0   0 141  0   0  21   0   0   0  0.14545455
## 30   0   0   0  13   0 73   2   0   0   1   2  0.19780220
## 31   0   0   0   4   0  4 112   0   0   0   0  0.06666667
## 501  0   0   0   0  15  0   0 486   1   0   8  0.04705882
## 502  0   4   0   0   0  0   0   7  44   0   5  0.26666667
## 503  0  41   0  18   0  1   0   2   0 640  20  0.11357341
## 7    0  28   0   3   0  0   0   9   2  20 358  0.14761905
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

RAN RSP ns3 15

mn="All_pRAN_RSP_NS3_pen15" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pRAN_RSP_NS3_pen15.shp", layer: "All_pRAN_RSP_NS3_pen15"
## with 1045 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 1043   10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 24.64%
## Confusion matrix:
##     1  20 21 23  3 30 31 501 502 503   7 class.error
## 1   4   0  0  0  2  0  0   0   0   0   0   0.3333333
## 20  0 111 13  1  0  0  0   0   1  23  16   0.3272727
## 21  0  27 28  0  0  0  0   0   1   5   1   0.5483871
## 23  0   0  0 74  0  7  1   0   0  18   2   0.2745098
## 3   1   0  0  0 43  0  0  11   0   0   0   0.2181818
## 30  0   0  0  6  0 22  3   0   0   1   1   0.3333333
## 31  0   0  0  6  0  4 29   0   0   1   0   0.2750000
## 501 0   1  0  0 13  0  0 151   0   0   5   0.1117647
## 502 0   7  1  0  0  0  0   2  10   0   2   0.5454545
## 503 0  22  1 10  0  1  0   0   0 204   6   0.1639344
## 7   0  16  0  1  0  1  0   8   1   7 110   0.2361111
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

RAN RSP ns3 30

mn="All_pRAN_RSP_NS3_pen30" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pRAN_RSP_NS3_pen30.shp", layer: "All_pRAN_RSP_NS3_pen30"
## with 2037 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 2034   10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 20.94%
## Confusion matrix:
##      1  20 21  23  3 30 31 501 502 503   7 class.error
## 1   10   0  0   0  1  0  0   0   0   0   0  0.09090909
## 20   0 227 18   0  0  0  0   6   0  46  21  0.28616352
## 21   0  48 58   0  0  0  0   1   1   6   0  0.49122807
## 23   0   0  0 148  0 10  6   0   0  23   8  0.24102564
## 3    1   0  0   0 84  0  0  25   0   0   0  0.23636364
## 30   0   0  0  14  0 43  2   0   0   2   1  0.30645161
## 31   0   0  0  15  0  2 63   0   0   0   0  0.21250000
## 501  0   3  0   0 20  0  0 306   1   0  10  0.10000000
## 502  0   3  2   0  1  0  0   1  30   1   3  0.26829268
## 503  0  30  2  15  0  0  1   0   1 417  16  0.13485477
## 7    0  21  2   3  0  3  0  15   2  13 222  0.20996441
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

RAN RSP ns3 45

mn="All_pRAN_RSP_NS3_pen45" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pRAN_RSP_NS3_pen45.shp", layer: "All_pRAN_RSP_NS3_pen45"
## with 3037 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 3034   10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 18.19%
## Confusion matrix:
##      1  20  21  23   3 30 31 501 502 503   7 class.error
## 1   15   0   0   0   2  0  0   0   0   0   0  0.11764706
## 20   0 353  18   0   0  0  0   4   1  64  31  0.25053079
## 21   0  58 103   0   0  0  0   0   0   7   2  0.39411765
## 23   0   0   0 221   0 18  6   0   0  32  11  0.23263889
## 3    2   0   0   0 131  0  0  32   0   0   0  0.20606061
## 30   0   0   0  15   0 66  5   0   0   2   3  0.27472527
## 31   0   0   0  16   0  5 99   0   0   0   0  0.17500000
## 501  0   3   0   0  22  0  0 471   1   0  13  0.07647059
## 502  0   7   1   0   0  0  0   1  44   1   6  0.26666667
## 503  0  43   2  20   0  2  0   0   1 638  16  0.11634349
## 7    0  27   2   2   0  2  0  20   4  22 341  0.18809524
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

ns5

SNA RSP ns5 15

mn="All_pSNA_RSP_NS5_pen15" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pSNA_RSP_NS5_pen15.shp", layer: "All_pSNA_RSP_NS5_pen15"
## with 355 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 355  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 21.97%
## Confusion matrix:
##     1 20 21 23  3 30 31 501 502 503  7 class.error
## 1   1  0  0  0  1  0  0   0   0   0  0  0.50000000
## 20  0 31  6  0  0  0  0   0   0   8  3  0.35416667
## 21  0  8 10  0  0  0  0   1   0   3  0  0.54545455
## 23  0  0  0 27  0  2  0   0   0   0  1  0.10000000
## 3   1  0  0  0 16  0  0   3   0   0  0  0.20000000
## 30  0  0  0  4  0  4  0   0   0   0  0  0.50000000
## 31  0  0  0  0  0  1 12   0   0   0  0  0.07692308
## 501 0  0  0  0  2  0  0  61   0   0  2  0.06153846
## 502 0  3  0  0  0  0  0   2   2   0  0  0.71428571
## 503 0  3  1  0  0  0  0   0   0  76  7  0.12643678
## 7   0  4  0  0  0  0  0   2   0  10 37  0.30188679
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

SNA RSP ns5 30

mn="All_pSNA_RSP_NS5_pen30" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pSNA_RSP_NS5_pen30.shp", layer: "All_pSNA_RSP_NS5_pen30"
## with 674 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 673  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 16.79%
## Confusion matrix:
##     1 20 21 23  3 30 31 501 502 503  7 class.error
## 1   2  0  0  0  1  0  0   0   0   0  0  0.33333333
## 20  0 66  3  0  0  0  0   1   0  12  8  0.26666667
## 21  0 12 20  0  0  0  0   0   0   1  0  0.39393939
## 23  0  0  0 46  0  3  2   0   0   0  4  0.16363636
## 3   1  0  0  0 35  0  0   3   0   0  0  0.10256410
## 30  0  0  0  8  0  6  0   0   0   0  1  0.60000000
## 31  0  0  0  0  0  1 25   0   0   0  0  0.03846154
## 501 0  0  0  0  4  0  0 124   0   0  1  0.03875969
## 502 0  3  1  0  0  0  0   3   5   0  2  0.64285714
## 503 0  9  0  1  0  0  0   0   0 152  6  0.09523810
## 7   0  6  0  2  0  0  0   2   0  12 79  0.21782178
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

SNA RSP ns5 45

mn="All_pSNA_RSP_NS5_pen45" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pSNA_RSP_NS5_pen45.shp", layer: "All_pSNA_RSP_NS5_pen45"
## with 992 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 991  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 15.44%
## Confusion matrix:
##     1 20 21 23  3 30 31 501 502 503   7 class.error
## 1   3  0  0  0  1  0  0   0   0   0   0  0.25000000
## 20  0 97  7  0  0  0  0   1   0  16   9  0.25384615
## 21  0 14 30  0  0  0  0   0   0   1   0  0.33333333
## 23  0  0  0 70  0  4  2   0   0   2   3  0.13580247
## 3   1  0  0  0 52  0  0   5   0   0   0  0.10344828
## 30  0  0  0  8  0 10  1   0   0   0   1  0.50000000
## 31  0  0  0  1  0  2 36   0   0   0   0  0.07692308
## 501 0  0  0  0  6  0  0 184   0   0   2  0.04166667
## 502 0  6  1  0  0  0  0   6   7   0   1  0.66666667
## 503 0 11  0  4  0  0  0   0   0 230   7  0.08730159
## 7   0 10  0  2  0  0  0   5   0  13 119  0.20134228
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

RAN RSP ns5 15

mn="All_pRAN_RSP_NS5_pen15" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pRAN_RSP_NS5_pen15.shp", layer: "All_pRAN_RSP_NS5_pen15"
## with 355 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 355  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 25.63%
## Confusion matrix:
##     1 20 21 23  3 30 31 501 502 503  7 class.error
## 1   2  0  0  0  0  0  0   0   0   0  0   0.0000000
## 20  0 33  5  0  0  0  0   1   0   6  3   0.3125000
## 21  0 11 10  0  0  0  0   0   0   1  0   0.5454545
## 23  0  0  0 18  0  2  3   0   0   5  2   0.4000000
## 3   0  0  0  0 13  0  0   7   0   0  0   0.3500000
## 30  0  0  0  5  0  1  2   0   0   0  0   0.8750000
## 31  0  0  0  3  0  0 10   0   0   0  0   0.2307692
## 501 0  0  0  0  7  0  0  58   0   0  0   0.1076923
## 502 0  0  0  0  0  0  0   1   5   0  1   0.2857143
## 503 0  6  2  1  0  0  0   0   0  76  2   0.1264368
## 7   0  9  0  3  0  0  0   2   0   1 38   0.2830189
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

RAN RSP ns5 30

mn="All_pRAN_RSP_NS5_pen30" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pRAN_RSP_NS5_pen30.shp", layer: "All_pRAN_RSP_NS5_pen30"
## with 674 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 674  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 22.26%
## Confusion matrix:
##     1 20 21 23  3 30 31 501 502 503  7 class.error
## 1   2  0  0  0  2  0  0   0   0   0  0   0.5000000
## 20  0 63  8  0  0  0  0   0   2  11  6   0.3000000
## 21  0 15 16  0  0  0  0   0   0   2  0   0.5151515
## 23  0  0  0 44  0  4  0   0   0   6  1   0.2000000
## 3   1  0  0  0 25  0  0  13   0   0  0   0.3589744
## 30  0  0  0  5  0  7  2   0   0   0  1   0.5333333
## 31  0  0  0  1  0  3 22   0   0   0  0   0.1538462
## 501 0  1  0  0 11  0  0 115   0   0  2   0.1085271
## 502 0  3  1  0  0  0  0   4   4   1  1   0.7142857
## 503 0  8  3  8  0  0  0   0   0 144  5   0.1428571
## 7   0  7  0  1  0  1  0   2   0   8 82   0.1881188
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

RAN RSP ns5 45

mn="All_pRAN_RSP_NS5_pen45" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pRAN_RSP_NS5_pen45.shp", layer: "All_pRAN_RSP_NS5_pen45"
## with 992 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 992  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 17.84%
## Confusion matrix:
##     1 20 21 23  3 30 31 501 502 503   7 class.error
## 1   3  0  0  0  2  0  0   0   0   0   0  0.40000000
## 20  0 93  8  0  0  0  0   0   1  15  13  0.28461538
## 21  0 16 28  0  0  0  0   0   0   1   0  0.37777778
## 23  0  0  0 57  0  5  2   0   0  13   4  0.29629630
## 3   0  0  0  0 46  0  0  12   0   0   0  0.20689655
## 30  0  0  0  8  0  7  5   0   0   0   0  0.65000000
## 31  0  0  0  2  0  1 36   0   0   0   0  0.07692308
## 501 0  0  0  0  9  0  0 181   0   0   2  0.05729167
## 502 0  3  0  0  0  0  0   2  15   0   1  0.28571429
## 503 0 10  2  6  0  0  0   0   0 228   6  0.09523810
## 7   0 11  1  2  0  0  0   8   0   6 121  0.18791946
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

ns7

SNA RSP ns7 15

mn="All_pSNA_RSP_NS7_pen15" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pSNA_RSP_NS7_pen15.shp", layer: "All_pSNA_RSP_NS7_pen15"
## with 127 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 126  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 20.63%
## Confusion matrix:
##     20 21 23 3 30 31 501 502 503  7 class.error
## 20  12  1  0 0  0  0   0   0   4  0   0.2941176
## 21   2  2  0 0  0  0   0   0   0  0   0.5000000
## 23   0  0 11 0  0  0   0   0   0  0   0.0000000
## 3    0  0  0 6  0  0   1   0   0  0   0.1428571
## 30   0  0  1 0  0  0   0   0   0  1   1.0000000
## 31   0  0  1 0  0  3   0   0   0  0   0.2500000
## 501  0  0  0 0  0  0  26   0   0  0   0.0000000
## 502  1  0  0 0  0  0   2   0   0  0   1.0000000
## 503  2  0  0 0  0  0   0   0  26  3   0.1612903
## 7    1  0  0 0  0  0   0   0   6 14   0.3333333
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

SNA RSP ns7 30

mn="All_pSNA_RSP_NS7_pen30" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pSNA_RSP_NS7_pen30.shp", layer: "All_pSNA_RSP_NS7_pen30"
## with 226 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 225  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 18.67%
## Confusion matrix:
##     20 21 23  3 30 31 501 502 503  7 class.error
## 20  18  0  0  0  0  0   0   0   7  2   0.3333333
## 21   3  2  0  0  0  0   1   0   0  0   0.6666667
## 23   0  0 18  0  0  0   0   0   1  1   0.1000000
## 3    0  0  0 13  0  0   0   0   0  0   0.0000000
## 30   0  0  2  0  0  0   0   0   0  1   1.0000000
## 31   0  0  0  0  0  7   0   0   0  0   0.0000000
## 501  0  0  0  0  0  0  49   0   0  1   0.0200000
## 502  1  0  0  0  0  0   4   0   0  0   1.0000000
## 503  5  0  0  0  0  0   0   0  50  2   0.1228070
## 7    2  0  0  0  0  0   1   0   8 26   0.2972973
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

SNA RSP ns7 45

mn="All_pSNA_RSP_NS7_pen45" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pSNA_RSP_NS7_pen45.shp", layer: "All_pSNA_RSP_NS7_pen45"
## with 321 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 320  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 15%
## Confusion matrix:
##     20 21 23  3 30 31 501 502 503  7 class.error
## 20  27  1  0  0  0  0   0   0   4  4  0.25000000
## 21   4  4  0  0  0  0   0   0   0  0  0.50000000
## 23   0  0 24  0  1  1   0   0   0  2  0.14285714
## 3    0  0  0 18  0  0   1   0   0  0  0.05263158
## 30   0  0  3  0  0  0   0   0   0  1  1.00000000
## 31   0  0  2  0  0  8   0   0   0  0  0.20000000
## 501  0  0  0  1  0  0  73   0   0  1  0.02666667
## 502  3  0  0  0  0  0   3   0   0  0  1.00000000
## 503  3  0  0  0  0  0   0   0  77  3  0.07228916
## 7    2  0  0  0  0  0   1   0   7 41  0.19607843
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

RAN RSP ns7 15

mn="All_pRAN_RSP_NS7_pen15" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pRAN_RSP_NS7_pen15.shp", layer: "All_pRAN_RSP_NS7_pen15"
## with 127 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 127  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 25.98%
## Confusion matrix:
##     1 20 21 23 3 30 31 501 502 503  7 class.error
## 1   0  0  0  0 1  0  0   0   0   0  0  1.00000000
## 20  0 11  1  0 0  0  0   0   0   2  3  0.35294118
## 21  0  3  1  0 0  0  0   0   0   0  0  0.75000000
## 23  0  0  0  7 0  0  2   0   0   2  0  0.36363636
## 3   0  0  0  0 7  0  0   0   0   0  0  0.00000000
## 30  0  0  0  1 0  0  0   0   0   0  1  1.00000000
## 31  0  0  0  1 0  0  3   0   0   0  0  0.25000000
## 501 0  0  0  0 1  0  0  24   1   0  0  0.07692308
## 502 0  2  0  0 0  0  0   1   0   0  0  1.00000000
## 503 0  3  0  1 0  0  0   0   0  26  1  0.16129032
## 7   0  2  0  0 0  1  0   0   0   3 15  0.28571429
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

RAN RSP ns7 30

mn="All_pRAN_RSP_NS7_pen30" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pRAN_RSP_NS7_pen30.shp", layer: "All_pRAN_RSP_NS7_pen30"
## with 226 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 226  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 22.57%
## Confusion matrix:
##     1 20 21 23  3 30 31 501 502 503  7 class.error
## 1   0  0  0  0  1  0  0   0   0   0  0   1.0000000
## 20  0 16  1  0  0  0  0   0   0   5  5   0.4074074
## 21  0  4  1  0  0  0  0   1   0   0  0   0.8333333
## 23  0  0  0 17  0  0  1   0   0   2  0   0.1500000
## 3   0  0  0  0 11  0  0   2   0   0  0   0.1538462
## 30  0  0  0  1  0  1  1   0   0   0  0   0.6666667
## 31  0  0  0  1  0  1  5   0   0   0  0   0.2857143
## 501 0  0  0  0  2  0  0  48   0   0  0   0.0400000
## 502 0  1  0  0  0  0  0   3   1   0  0   0.8000000
## 503 0  4  0  2  0  0  0   0   0  48  3   0.1578947
## 7   0  3  0  1  0  0  0   1   0   5 27   0.2702703
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

RAN RSP ns7 45

mn="All_pRAN_RSP_NS7_pen45" 

shpPoint<-readOGR(paste(point_shp_folder,mn,".shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\allTrainingSamples_shp\All_pRAN_RSP_NS7_pen45.shp", layer: "All_pRAN_RSP_NS7_pen45"
## with 321 features
## It has 1 fields
sampData <- extract(covStack, shpPoint, sp = TRUE,method = "simple") 

sampData<-sampData@data

sampData<-sampData[sampData$soilID %in% soil_type,]

sampData<-na.omit(sampData)

print(dim(sampData))
## [1] 321  10
sampleNum_dict[mn]<-nrow(sampData)

sampData$Bedrock<- droplevels(as.factor(sampData$Bedrock))
sampData$soilID<- droplevels(as.factor(sampData$soilID))

RF_model<-randomForest(soilID ~.,data = sampData, 
                       importance = TRUE, proximity = FALSE,
                       ntree=1000,type="classification")

varImpPlot(RF_model)

print(RF_model)
## 
## Call:
##  randomForest(formula = soilID ~ ., data = sampData, importance = TRUE,      proximity = FALSE, ntree = 1000, type = "classification") 
##                Type of random forest: classification
##                      Number of trees: 1000
## No. of variables tried at each split: 3
## 
##         OOB estimate of  error rate: 17.13%
## Confusion matrix:
##     1 20 21 23  3 30 31 501 502 503  7 class.error
## 1   0  0  0  0  1  0  0   0   0   0  0  1.00000000
## 20  0 25  1  0  0  0  0   0   0   4  6  0.30555556
## 21  0  4  4  0  0  0  0   0   0   0  0  0.50000000
## 23  0  0  0 20  0  1  2   0   0   5  0  0.28571429
## 3   1  0  0  0 16  0  0   2   0   0  0  0.15789474
## 30  0  0  0  1  0  3  0   0   0   0  0  0.25000000
## 31  0  0  0  1  0  0  9   0   0   0  0  0.10000000
## 501 0  0  0  0  1  0  0  73   0   0  1  0.02666667
## 502 0  1  0  0  0  0  0   3   1   0  1  0.83333333
## 503 0  4  0  5  0  0  0   0   0  72  2  0.13253012
## 7   0  3  0  0  0  0  0   1   0   4 43  0.15686275
map_RF <- predict(covStack, RF_model, paste(result_tif_folder,mn,".tif",sep=""),
                  format = "GTiff", datatype = "FLT4S", overwrite = TRUE)

rm("mn","shpPoint","sampData","RF_model","map_RF")

计算精度

#设置最终结果tif的保存路径
result_tif_folder="E:/soilPaper/modling/result_mapTif/"

result_map_name<-c("All_pSNA_DEM_NS3_pen15","All_pSNA_DEM_NS5_pen15","All_pSNA_DEM_NS7_pen15",
                   "All_pRAN_DEM_NS3_pen15","All_pRAN_DEM_NS5_pen15","All_pRAN_DEM_NS7_pen15",
                   "All_pSNA_DEM_NS3_pen30","All_pSNA_DEM_NS5_pen30","All_pSNA_DEM_NS7_pen30",
                   "All_pRAN_DEM_NS3_pen30","All_pRAN_DEM_NS5_pen30","All_pRAN_DEM_NS7_pen30",
                   "All_pSNA_DEM_NS3_pen45","All_pSNA_DEM_NS5_pen45","All_pSNA_DEM_NS7_pen45",
                   "All_pRAN_DEM_NS3_pen45","All_pRAN_DEM_NS5_pen45","All_pRAN_DEM_NS7_pen45",
                   "All_pSNA_Slope_NS3_pen15","All_pSNA_Slope_NS5_pen15","All_pSNA_Slope_NS7_pen15",
                   "All_pRAN_Slope_NS3_pen15","All_pRAN_Slope_NS5_pen15","All_pRAN_Slope_NS7_pen15",
                   "All_pSNA_Slope_NS3_pen30","All_pSNA_Slope_NS5_pen30","All_pSNA_Slope_NS7_pen30",
                   "All_pRAN_Slope_NS3_pen30","All_pRAN_Slope_NS5_pen30","All_pRAN_Slope_NS7_pen30",
                   "All_pSNA_Slope_NS3_pen45","All_pSNA_Slope_NS5_pen45","All_pSNA_Slope_NS7_pen45",
                   "All_pRAN_Slope_NS3_pen45","All_pRAN_Slope_NS5_pen45","All_pRAN_Slope_NS7_pen45",
                   "All_pSNA_PlanC_NS3_pen15","All_pSNA_PlanC_NS5_pen15","All_pSNA_PlanC_NS7_pen15",
                   "All_pRAN_PlanC_NS3_pen15","All_pRAN_PlanC_NS5_pen15","All_pRAN_PlanC_NS7_pen15",
                   "All_pSNA_PlanC_NS3_pen30","All_pSNA_PlanC_NS5_pen30","All_pSNA_PlanC_NS7_pen30",
                   "All_pRAN_PlanC_NS3_pen30","All_pRAN_PlanC_NS5_pen30","All_pRAN_PlanC_NS7_pen30",
                   "All_pSNA_PlanC_NS3_pen45","All_pSNA_PlanC_NS5_pen45","All_pSNA_PlanC_NS7_pen45",
                   "All_pRAN_PlanC_NS3_pen45","All_pRAN_PlanC_NS5_pen45","All_pRAN_PlanC_NS7_pen45",
                   "All_pSNA_ProfileC_NS3_pen15","All_pSNA_ProfileC_NS5_pen15","All_pSNA_ProfileC_NS7_pen15",
                   "All_pRAN_ProfileC_NS3_pen15","All_pRAN_ProfileC_NS5_pen15","All_pRAN_ProfileC_NS7_pen15",
                   "All_pSNA_ProfileC_NS3_pen30","All_pSNA_ProfileC_NS5_pen30","All_pSNA_ProfileC_NS7_pen30",
                   "All_pRAN_ProfileC_NS3_pen30","All_pRAN_ProfileC_NS5_pen30","All_pRAN_ProfileC_NS7_pen30",
                   "All_pSNA_ProfileC_NS3_pen45","All_pSNA_ProfileC_NS5_pen45","All_pSNA_ProfileC_NS7_pen45",
                   "All_pRAN_ProfileC_NS3_pen45","All_pRAN_ProfileC_NS5_pen45","All_pRAN_ProfileC_NS7_pen45",
                   "All_pSNA_TWI_NS3_pen15","All_pSNA_TWI_NS5_pen15","All_pSNA_TWI_NS7_pen15",
                   "All_pRAN_TWI_NS3_pen15","All_pRAN_TWI_NS5_pen15","All_pRAN_TWI_NS7_pen15",
                   "All_pSNA_TWI_NS3_pen30","All_pSNA_TWI_NS5_pen30","All_pSNA_TWI_NS7_pen30",
                   "All_pRAN_TWI_NS3_pen30","All_pRAN_TWI_NS5_pen30","All_pRAN_TWI_NS7_pen30",
                   "All_pSNA_TWI_NS3_pen45","All_pSNA_TWI_NS5_pen45","All_pSNA_TWI_NS7_pen45",
                   "All_pRAN_TWI_NS3_pen45","All_pRAN_TWI_NS5_pen45","All_pRAN_TWI_NS7_pen45",
                   "All_pSNA_LSF_NS3_pen15","All_pSNA_LSF_NS5_pen15","All_pSNA_LSF_NS7_pen15",
                   "All_pRAN_LSF_NS3_pen15","All_pRAN_LSF_NS5_pen15","All_pRAN_LSF_NS7_pen15",
                   "All_pSNA_LSF_NS3_pen30","All_pSNA_LSF_NS5_pen30","All_pSNA_LSF_NS7_pen30",
                   "All_pRAN_LSF_NS3_pen30","All_pRAN_LSF_NS5_pen30","All_pRAN_LSF_NS7_pen30",
                   "All_pSNA_LSF_NS3_pen45","All_pSNA_LSF_NS5_pen45","All_pSNA_LSF_NS7_pen45",
                   "All_pRAN_LSF_NS3_pen45","All_pRAN_LSF_NS5_pen45","All_pRAN_LSF_NS7_pen45",
                   "All_pSNA_VD_NS3_pen15","All_pSNA_VD_NS5_pen15","All_pSNA_VD_NS7_pen15",
                   "All_pRAN_VD_NS3_pen15","All_pRAN_VD_NS5_pen15","All_pRAN_VD_NS7_pen15",
                   "All_pSNA_VD_NS3_pen30","All_pSNA_VD_NS5_pen30","All_pSNA_VD_NS7_pen30",
                   "All_pRAN_VD_NS3_pen30","All_pRAN_VD_NS5_pen30","All_pRAN_VD_NS7_pen30",
                   "All_pSNA_VD_NS3_pen45","All_pSNA_VD_NS5_pen45","All_pSNA_VD_NS7_pen45",
                   "All_pRAN_VD_NS3_pen45","All_pRAN_VD_NS5_pen45","All_pRAN_VD_NS7_pen45",
                   "All_pSNA_RSP_NS3_pen15","All_pSNA_RSP_NS5_pen15","All_pSNA_RSP_NS7_pen15",
                   "All_pRAN_RSP_NS3_pen15","All_pRAN_RSP_NS5_pen15","All_pRAN_RSP_NS7_pen15",
                   "All_pSNA_RSP_NS3_pen30","All_pSNA_RSP_NS5_pen30","All_pSNA_RSP_NS7_pen30",
                   "All_pRAN_RSP_NS3_pen30","All_pRAN_RSP_NS5_pen30","All_pRAN_RSP_NS7_pen30",
                   "All_pSNA_RSP_NS3_pen45","All_pSNA_RSP_NS5_pen45","All_pSNA_RSP_NS7_pen45",
                   "All_pRAN_RSP_NS3_pen45","All_pRAN_RSP_NS5_pen45","All_pRAN_RSP_NS7_pen45")

resultCovStack<-raster(paste(result_tif_folder,result_map_name[1],".tif",sep = ""))
for (i in 2:length(result_map_name)) {
  resultCovStack <- stack(resultCovStack, raster(paste(result_tif_folder,result_map_name[i],".tif",sep = "")))
}

validationPoint<-readOGR(paste(result_tif_folder,"validationPoint.shp",sep = "")) ###
## OGR data source with driver: ESRI Shapefile 
## Source: "E:\soilPaper\modling\result_mapTif\validationPoint.shp", layer: "validationPoint"
## with 99 features
## It has 3 fields
vp_data <- extract(resultCovStack, validationPoint, sp = TRUE,method = "simple") 
vp_data<-na.omit(vp_data@data)


vp_data<-vp_data[vp_data$trueType %in% soil_type,]

print(nrow(vp_data))
## [1] 90
precision_df<-data.frame("method"=rep(NA,length(result_map_name)),
                         "factor"=rep(NA,length(result_map_name)),
                         "NS"=rep(NA,length(result_map_name)),
                         "percent"=rep(NA,length(result_map_name)),
                         "precisionValue"=rep(NA,length(result_map_name)),
                         "sampleNum"=rep(NA,length(result_map_name)))

for (i in 1:length(result_map_name)){
  fna<-result_map_name[i]
  ns_split<-unlist(strsplit(fna,"_"))
  if (length(ns_split)==5){
    precision_df[i,]$method<-ns_split[2]
    precision_df[i,]$factor<-ns_split[3]
    precision_df[i,]$NS<-ns_split[4]
    precision_df[i,]$percent<-ns_split[5]
    precision_df[i,]$precisionValue<-round( sum(vp_data$trueType==vp_data[fna])/nrow(vp_data),4)
    precision_df[i,]$sampleNum<-as.vector(unlist(sampleNum_dict[fna]))
  }

}

precision_oldSoilMap<-round( sum(vp_data$trueType==vp_data$oldSoilMap)/nrow(vp_data),4)
print(precision_oldSoilMap)
## [1] 0.6333
print(precision_df)
##     method   factor  NS percent precisionValue sampleNum
## 1     pSNA      DEM NS3   pen15         0.3222      1040
## 2     pSNA      DEM NS5   pen15         0.2556       354
## 3     pSNA      DEM NS7   pen15         0.4778       130
## 4     pRAN      DEM NS3   pen15         0.6778      1042
## 5     pRAN      DEM NS5   pen15         0.7000       356
## 6     pRAN      DEM NS7   pen15         0.6778       131
## 7     pSNA      DEM NS3   pen30         0.3778      2040
## 8     pSNA      DEM NS5   pen30         0.4222       677
## 9     pSNA      DEM NS7   pen30         0.3889       226
## 10    pRAN      DEM NS3   pen30         0.6778      2042
## 11    pRAN      DEM NS5   pen30         0.7000       679
## 12    pRAN      DEM NS7   pen30         0.6889       227
## 13    pSNA      DEM NS3   pen45         0.4667      3036
## 14    pSNA      DEM NS5   pen45         0.4333       993
## 15    pSNA      DEM NS7   pen45         0.3889       326
## 16    pRAN      DEM NS3   pen45         0.6444      3038
## 17    pRAN      DEM NS5   pen45         0.6778       995
## 18    pRAN      DEM NS7   pen45         0.6778       327
## 19    pSNA    Slope NS3   pen15         0.7333       994
## 20    pSNA    Slope NS5   pen15         0.6667       336
## 21    pSNA    Slope NS7   pen15         0.6667       121
## 22    pRAN    Slope NS3   pen15         0.6889       996
## 23    pRAN    Slope NS5   pen15         0.6000       336
## 24    pRAN    Slope NS7   pen15         0.6444       121
## 25    pSNA    Slope NS3   pen30         0.7000      1947
## 26    pSNA    Slope NS5   pen30         0.6889       636
## 27    pSNA    Slope NS7   pen30         0.6000       214
## 28    pRAN    Slope NS3   pen30         0.6222      1948
## 29    pRAN    Slope NS5   pen30         0.6333       636
## 30    pRAN    Slope NS7   pen30         0.6444       214
## 31    pSNA    Slope NS3   pen45         0.7333      2885
## 32    pSNA    Slope NS5   pen45         0.6444       929
## 33    pSNA    Slope NS7   pen45         0.6556       307
## 34    pRAN    Slope NS3   pen45         0.6556      2886
## 35    pRAN    Slope NS5   pen45         0.6333       931
## 36    pRAN    Slope NS7   pen45         0.7000       307
## 37    pSNA    PlanC NS3   pen15         0.6333      1011
## 38    pSNA    PlanC NS5   pen15         0.6778       345
## 39    pSNA    PlanC NS7   pen15         0.5333       129
## 40    pRAN    PlanC NS3   pen15         0.6889      1011
## 41    pRAN    PlanC NS5   pen15         0.5889       345
## 42    pRAN    PlanC NS7   pen15         0.6556       129
## 43    pSNA    PlanC NS3   pen30         0.6222      1973
## 44    pSNA    PlanC NS5   pen30         0.6778       649
## 45    pSNA    PlanC NS7   pen30         0.5222       227
## 46    pRAN    PlanC NS3   pen30         0.6556      1973
## 47    pRAN    PlanC NS5   pen30         0.6556       650
## 48    pRAN    PlanC NS7   pen30         0.6222       227
## 49    pSNA    PlanC NS3   pen45         0.6222      2937
## 50    pSNA    PlanC NS5   pen45         0.6556       953
## 51    pSNA    PlanC NS7   pen45         0.5667       319
## 52    pRAN    PlanC NS3   pen45         0.6667      2937
## 53    pRAN    PlanC NS5   pen45         0.6667       954
## 54    pRAN    PlanC NS7   pen45         0.6889       320
## 55    pSNA ProfileC NS3   pen15         0.6444       996
## 56    pSNA ProfileC NS5   pen15         0.5778       338
## 57    pSNA ProfileC NS7   pen15         0.6222       122
## 58    pRAN ProfileC NS3   pen15         0.6889       998
## 59    pRAN ProfileC NS5   pen15         0.6556       340
## 60    pRAN ProfileC NS7   pen15         0.6778       122
## 61    pSNA ProfileC NS3   pen30         0.6444      1946
## 62    pSNA ProfileC NS5   pen30         0.7000       636
## 63    pSNA ProfileC NS7   pen30         0.5778       215
## 64    pRAN ProfileC NS3   pen30         0.6778      1946
## 65    pRAN ProfileC NS5   pen30         0.7111       638
## 66    pRAN ProfileC NS7   pen30         0.6667       215
## 67    pSNA ProfileC NS3   pen45         0.6444      2895
## 68    pSNA ProfileC NS5   pen45         0.6444       934
## 69    pSNA ProfileC NS7   pen45         0.6333       307
## 70    pRAN ProfileC NS3   pen45         0.6222      2894
## 71    pRAN ProfileC NS5   pen45         0.6667       936
## 72    pRAN ProfileC NS7   pen45         0.6778       307
## 73    pSNA      TWI NS3   pen15         0.7333       983
## 74    pSNA      TWI NS5   pen15         0.8000       337
## 75    pSNA      TWI NS7   pen15         0.7111       122
## 76    pRAN      TWI NS3   pen15         0.6667       983
## 77    pRAN      TWI NS5   pen15         0.6444       337
## 78    pRAN      TWI NS7   pen15         0.6333       122
## 79    pSNA      TWI NS3   pen30         0.6889      1919
## 80    pSNA      TWI NS5   pen30         0.7667       634
## 81    pSNA      TWI NS7   pen30         0.6889       216
## 82    pRAN      TWI NS3   pen30         0.6222      1918
## 83    pRAN      TWI NS5   pen30         0.6444       634
## 84    pRAN      TWI NS7   pen30         0.6444       216
## 85    pSNA      TWI NS3   pen45         0.6889      2857
## 86    pSNA      TWI NS5   pen45         0.7111       934
## 87    pSNA      TWI NS7   pen45         0.6667       310
## 88    pRAN      TWI NS3   pen45         0.6778      2855
## 89    pRAN      TWI NS5   pen45         0.6556       934
## 90    pRAN      TWI NS7   pen45         0.7111       310
## 91    pSNA      LSF NS3   pen15         0.6889       985
## 92    pSNA      LSF NS5   pen15         0.6000       334
## 93    pSNA      LSF NS7   pen15         0.6111       121
## 94    pRAN      LSF NS3   pen15         0.6556       985
## 95    pRAN      LSF NS5   pen15         0.6444       334
## 96    pRAN      LSF NS7   pen15         0.6778       121
## 97    pSNA      LSF NS3   pen30         0.7333      1924
## 98    pSNA      LSF NS5   pen30         0.6333       629
## 99    pSNA      LSF NS7   pen30         0.6333       217
## 100   pRAN      LSF NS3   pen30         0.6778      1922
## 101   pRAN      LSF NS5   pen30         0.6333       629
## 102   pRAN      LSF NS7   pen30         0.7111       217
## 103   pSNA      LSF NS3   pen45         0.7222      2856
## 104   pSNA      LSF NS5   pen45         0.6444       927
## 105   pSNA      LSF NS7   pen45         0.6333       309
## 106   pRAN      LSF NS3   pen45         0.6556      2853
## 107   pRAN      LSF NS5   pen45         0.6556       927
## 108   pRAN      LSF NS7   pen45         0.6889       309
## 109   pSNA       VD NS3   pen15         0.3778      1040
## 110   pSNA       VD NS5   pen15         0.4111       355
## 111   pSNA       VD NS7   pen15         0.4556       256
## 112   pRAN       VD NS3   pen15         0.6111      1039
## 113   pRAN       VD NS5   pen15         0.5778       355
## 114   pRAN       VD NS7   pen15         0.6111       129
## 115   pSNA       VD NS3   pen30         0.5222      2043
## 116   pSNA       VD NS5   pen30         0.4444       674
## 117   pSNA       VD NS7   pen30         0.4000       226
## 118   pRAN       VD NS3   pen30         0.6778      2042
## 119   pRAN       VD NS5   pen30         0.6778       675
## 120   pRAN       VD NS7   pen30         0.6444       227
## 121   pSNA       VD NS3   pen45         0.5667      3035
## 122   pSNA       VD NS5   pen45         0.4889       992
## 123   pSNA       VD NS7   pen45         0.4000       322
## 124   pRAN       VD NS3   pen45         0.6333      3037
## 125   pRAN       VD NS5   pen45         0.6000       992
## 126   pRAN       VD NS7   pen45         0.6444       323
## 127   pSNA      RSP NS3   pen15         0.3667      1043
## 128   pSNA      RSP NS5   pen15         0.3889       355
## 129   pSNA      RSP NS7   pen15         0.4444       126
## 130   pRAN      RSP NS3   pen15         0.6111      1043
## 131   pRAN      RSP NS5   pen15         0.6000       355
## 132   pRAN      RSP NS7   pen15         0.6444       127
## 133   pSNA      RSP NS3   pen30         0.4556      2035
## 134   pSNA      RSP NS5   pen30         0.4333       673
## 135   pSNA      RSP NS7   pen30         0.4444       225
## 136   pRAN      RSP NS3   pen30         0.6444      2034
## 137   pRAN      RSP NS5   pen30         0.6667       674
## 138   pRAN      RSP NS7   pen30         0.6333       226
## 139   pSNA      RSP NS3   pen45         0.5556      3032
## 140   pSNA      RSP NS5   pen45         0.4889       991
## 141   pSNA      RSP NS7   pen45         0.3778       320
## 142   pRAN      RSP NS3   pen45         0.6444      3034
## 143   pRAN      RSP NS5   pen45         0.6556       992
## 144   pRAN      RSP NS7   pen45         0.6222       321
write.csv(precision_df,"结果精度_8单因子_origin.csv",row.names = F,fileEncoding="utf-8")


pdf_sna<-subset(precision_df,method=="pSNA")
pdf_ran<-subset(precision_df,method=="pRAN")

pdf_ran_mean<-aggregate(pdf_ran[,c("precisionValue","sampleNum")],by=list(method=pdf_ran$method,NS=pdf_ran$NS,percent=pdf_ran$percent),FUN=mean)
pdf_ran_mean$factor<-"Random"

precision_df_final<-rbind(pdf_sna,pdf_ran_mean)
print(precision_df_final)
##     method   factor  NS percent precisionValue sampleNum
## 1     pSNA      DEM NS3   pen15      0.3222000  1040.000
## 2     pSNA      DEM NS5   pen15      0.2556000   354.000
## 3     pSNA      DEM NS7   pen15      0.4778000   130.000
## 7     pSNA      DEM NS3   pen30      0.3778000  2040.000
## 8     pSNA      DEM NS5   pen30      0.4222000   677.000
## 9     pSNA      DEM NS7   pen30      0.3889000   226.000
## 13    pSNA      DEM NS3   pen45      0.4667000  3036.000
## 14    pSNA      DEM NS5   pen45      0.4333000   993.000
## 15    pSNA      DEM NS7   pen45      0.3889000   326.000
## 19    pSNA    Slope NS3   pen15      0.7333000   994.000
## 20    pSNA    Slope NS5   pen15      0.6667000   336.000
## 21    pSNA    Slope NS7   pen15      0.6667000   121.000
## 25    pSNA    Slope NS3   pen30      0.7000000  1947.000
## 26    pSNA    Slope NS5   pen30      0.6889000   636.000
## 27    pSNA    Slope NS7   pen30      0.6000000   214.000
## 31    pSNA    Slope NS3   pen45      0.7333000  2885.000
## 32    pSNA    Slope NS5   pen45      0.6444000   929.000
## 33    pSNA    Slope NS7   pen45      0.6556000   307.000
## 37    pSNA    PlanC NS3   pen15      0.6333000  1011.000
## 38    pSNA    PlanC NS5   pen15      0.6778000   345.000
## 39    pSNA    PlanC NS7   pen15      0.5333000   129.000
## 43    pSNA    PlanC NS3   pen30      0.6222000  1973.000
## 44    pSNA    PlanC NS5   pen30      0.6778000   649.000
## 45    pSNA    PlanC NS7   pen30      0.5222000   227.000
## 49    pSNA    PlanC NS3   pen45      0.6222000  2937.000
## 50    pSNA    PlanC NS5   pen45      0.6556000   953.000
## 51    pSNA    PlanC NS7   pen45      0.5667000   319.000
## 55    pSNA ProfileC NS3   pen15      0.6444000   996.000
## 56    pSNA ProfileC NS5   pen15      0.5778000   338.000
## 57    pSNA ProfileC NS7   pen15      0.6222000   122.000
## 61    pSNA ProfileC NS3   pen30      0.6444000  1946.000
## 62    pSNA ProfileC NS5   pen30      0.7000000   636.000
## 63    pSNA ProfileC NS7   pen30      0.5778000   215.000
## 67    pSNA ProfileC NS3   pen45      0.6444000  2895.000
## 68    pSNA ProfileC NS5   pen45      0.6444000   934.000
## 69    pSNA ProfileC NS7   pen45      0.6333000   307.000
## 73    pSNA      TWI NS3   pen15      0.7333000   983.000
## 74    pSNA      TWI NS5   pen15      0.8000000   337.000
## 75    pSNA      TWI NS7   pen15      0.7111000   122.000
## 79    pSNA      TWI NS3   pen30      0.6889000  1919.000
## 80    pSNA      TWI NS5   pen30      0.7667000   634.000
## 81    pSNA      TWI NS7   pen30      0.6889000   216.000
## 85    pSNA      TWI NS3   pen45      0.6889000  2857.000
## 86    pSNA      TWI NS5   pen45      0.7111000   934.000
## 87    pSNA      TWI NS7   pen45      0.6667000   310.000
## 91    pSNA      LSF NS3   pen15      0.6889000   985.000
## 92    pSNA      LSF NS5   pen15      0.6000000   334.000
## 93    pSNA      LSF NS7   pen15      0.6111000   121.000
## 97    pSNA      LSF NS3   pen30      0.7333000  1924.000
## 98    pSNA      LSF NS5   pen30      0.6333000   629.000
## 99    pSNA      LSF NS7   pen30      0.6333000   217.000
## 103   pSNA      LSF NS3   pen45      0.7222000  2856.000
## 104   pSNA      LSF NS5   pen45      0.6444000   927.000
## 105   pSNA      LSF NS7   pen45      0.6333000   309.000
## 109   pSNA       VD NS3   pen15      0.3778000  1040.000
## 110   pSNA       VD NS5   pen15      0.4111000   355.000
## 111   pSNA       VD NS7   pen15      0.4556000   256.000
## 115   pSNA       VD NS3   pen30      0.5222000  2043.000
## 116   pSNA       VD NS5   pen30      0.4444000   674.000
## 117   pSNA       VD NS7   pen30      0.4000000   226.000
## 121   pSNA       VD NS3   pen45      0.5667000  3035.000
## 122   pSNA       VD NS5   pen45      0.4889000   992.000
## 123   pSNA       VD NS7   pen45      0.4000000   322.000
## 127   pSNA      RSP NS3   pen15      0.3667000  1043.000
## 128   pSNA      RSP NS5   pen15      0.3889000   355.000
## 129   pSNA      RSP NS7   pen15      0.4444000   126.000
## 133   pSNA      RSP NS3   pen30      0.4556000  2035.000
## 134   pSNA      RSP NS5   pen30      0.4333000   673.000
## 135   pSNA      RSP NS7   pen30      0.4444000   225.000
## 139   pSNA      RSP NS3   pen45      0.5556000  3032.000
## 140   pSNA      RSP NS5   pen45      0.4889000   991.000
## 141   pSNA      RSP NS7   pen45      0.3778000   320.000
## 11    pRAN   Random NS3   pen15      0.6611250  1012.125
## 22    pRAN   Random NS5   pen15      0.6263875   344.750
## 34    pRAN   Random NS7   pen15      0.6527750   125.250
## 4     pRAN   Random NS3   pen30      0.6569500  1978.125
## 5     pRAN   Random NS5   pen30      0.6652750   651.875
## 6     pRAN   Random NS7   pen30      0.6569250   221.125
## 71    pRAN   Random NS3   pen45      0.6500000  2941.750
## 82    pRAN   Random NS5   pen45      0.6514125   957.625
## 94    pRAN   Random NS7   pen45      0.6763875   315.500
write.csv(precision_df_final,"结果精度_8单因子_final.csv",row.names = F,fileEncoding="utf-8")